首页 > 其他 > 详细

关闭定时器(setTimeout/clearTimeout|setInterval/clearInterval)

时间:2018-11-23 20:04:02      阅读:263      评论:0      收藏:0      [点我收藏+]

 1.1 开启Timeout程序: scope.setTimeout("functionName()" | functionHandle, timeValue) 返回值:timerID

  1.2 关闭Timeout程序: scope.clearTimeout(timerID);

  

  2.1 开启Interval程序: scope.setInterval("functionName()" | functionHandle, timeValue)  返回值:timerID

  2.2 关闭Interval程序: scope.clearInterval(timerID);

60秒倒计时:

  let _this = this
      this.sendState = true;
     let time = setInterval(function(){
          _this.countdown-=1;
          if(_this.countdown==0){
            clearInterval(time)
            _this.sendState = false;
            _this.countdown = 60
          }
          console.log(_this.countdown)
      },1000)

  

关闭定时器(setTimeout/clearTimeout|setInterval/clearInterval)

原文:https://www.cnblogs.com/lan-cheng/p/10008953.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!