定时器

  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);

  },
原文地址:https://www.cnblogs.com/dianzan/p/11731802.html