首页 > 其他 > 详细

vue中定时器设置和关闭页面时关闭定时器

时间:2019-04-10 15:49:12      阅读:1396      评论:0      收藏:0      [点我收藏+]

methods中

setTime() //设置定时器
{
this.clearTimeSet=setInterval(() => {
this.webSocketClientOnopen();
}, 1000);
},

clearTime() //清除定时器
{
clearInterval(this.clearTimeSet);
}

mounted 
mounted : function () //页面加载完毕就开始加载定时器
{
this.setTime();
}

beforeDestroy() { //页面关闭时清除定时器
  clearInterval(this.clearTimeSet);
},
 

vue中定时器设置和关闭页面时关闭定时器

原文:https://www.cnblogs.com/benbenbai/p/10683495.html

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