美文网首页
VUE代码规范

VUE代码规范

作者: 呆小狼 | 来源:发表于2017-09-25 16:47 被阅读0次
    import Vue from 'vue'
    
    import { XButton } from 'vux'
    import {Popup} from 'vue-ydui/dist/lib.px/popup'
    import {Button} from 'vue-ydui/dist/lib.px/button'
    
    Vue.component(Button.name, Button)
    Vue.component(Popup.name, Popup)
    export default {
        name: 'read',
        data() {
            return { 
                show1: false,
                outlineList:'',
                x:'',
                y:'',
                ok:''
            }
        }, 
        components: {
            XButton
        },
        mounted: function () {
            
        },
        methods: {
            abc: function () {
                this.show1 = true;
             },
    
            getPost:function(){ 
                this.axios.post('/olquestion/news',{"uid":10,"daily_id":1}).then(res=>{
                    this.outlineList = res.data.datas
                    console.log(this.outlineList.length)
                    // let choseList = this.outlineList[0].chose_single.split(' ');
                    // console.log(choseList);
                    let arr = []
                    this.outlineList.forEach((value,index) => {
                        arr.push(value.chose_single.split(' '));
                    });
                    // console.log(arr);
                    this.secondList = arr;
                    let x=0,y=0,i=0,ok=0;
                    let outlineList = res.data.datas;
                    for(i=0;i<outlineList.length;i++){
                        if(this.outlineList[i].result==1){
                            x++;
                            this.x = x;
                            ok=(x/outlineList.length)*100;
                            this.ok= ok;
                        }else{
                            y++;
                            this.y = y;
                        }
                    }
                    console.log(x,y,ok)   
                },function(err){
                    console.log(err)
                })
            },
            goAnchor(selector) {
                let anchor = this.$refs.aaa;
                console.log(selector)
                // var anchor = this.$refs.aaa.querySelector(selector)
                document.body.scrollTop = anchor.offsetTop
                document.documentElement.scrollTop = anchor.offsetTop; // firefox
            },
            share:function(){
                this.$router.push('/share')
            }
        },
        created () {
          this.abc()
          this.getPost()
        },
        onShareAppMessage: function () {
            
        }
    }
    

    标准

    相关文章

      网友评论

          本文标题:VUE代码规范

          本文链接:https://www.haomeiwen.com/subject/qzrdextx.html