VUE在生成页面时,有一个生命周期回调函数,确保在页面加载的不同阶段实现回调函数

比如页面在加载时,判断用户是否已经登陆过? 如果是特定URL选择不同的标签等功能实现?

我就是使用的vue created函数

<script>
  new Vue({
      el: '#app',
      data: {

      selected: '屌猫充值',
      diaomao_money:'0',
      diaomao_qq:'',
      score:'',
      seen:false,

      ad_type:'1',
      chongzhi_ad_type:'10',
      tixian_ad_type:'10',
      chongzhi_qq:'',

      chongzhi_money:'0.5',
      tixian_money: '10000',
      chongzhi_pay_type:'qqpay',



      },
      methods: {
            islogin(){
            if(true) { //this.score == 0 && this.diaomao_money == 0
                     this.$http.post('/m/islogin',{paytype:''},{emulateJSON:true}).then(function(res){
                        var obj = res.body  ; //获得返回的信息
                        if(obj.status){
                           this.score = obj.score;
                           this.diaomao_money = obj.money;
                           this.diaomao_qq = obj.qq;
                           this.chongzhi_qq = this.diaomao_qq;
                           this.seen = true;
                        }else{


                        }

                        },function(res){
                            console.log(res.status);
                        });
                  }
            }

          },created(){

                if(window.location.search.search('tixian') != -1){
                   this.$toast('屌猫后台欢迎您 一次变积分为人民币');
                   this.selected = '屌猫提现';
                }

                this.islogin();
            }
  })



  </script>

监听tab选项卡 变化?

vm.$watch('selected', function(nval, oval) {
    //alert('计数器值的变化 :' + oval + ' 变为 ' + nval + '!');
     if(nval..toString().indexof("投放记录") != -1)
       window.location.href="/m/guanggao_history";
  });

参考:

https://segmentfault.com/a/1190000008010666?utm_source=tag-newest

results matching ""

    No results matching ""