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)      
    },
}
原文地址:https://www.cnblogs.com/foxcharon/p/9327780.html