vue :没有全局变量的计数器

created:

created () {
   let num = null
   this.mFun(num)
},

methods:

methods:{
    mFun(m){
      if (m === null) {
        m = 0
      } else {
        m++
      }
      setTimeout(()=>{        
        console.log(m)
        this.mFun(m)
      },1000)      
    },
}

 

posted on 2018-07-18 10:35  fox_charon  阅读(172)  评论(0编辑  收藏  举报

导航