VUE代码规范

2017-09-25  本文已影响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 () {
        
    }
}

标准

上一篇 下一篇

猜你喜欢

热点阅读