定时器

  onLoad: function(opt) {
    let that = this;
    let n = this.data.n;
    function nowTime() {
      n++;
      console.log(n)
      if (timer) {}
      if (n > 5 && timer) {
        clearInterval(timer);
      }
    }
    var timer = setInterval(nowTime, 2000);

  },

 

posted @ 2019-10-24 13:58  ThisCall  阅读(107)  评论(0编辑  收藏  举报