data: {
return {
timer: null
}
},
created() {
this.timer = setInterval(....);
},
beforeDestroy() {
if(this.timer) { //如果定时器还在运行 或者直接关闭,不用判断
clearInterval(this.timer); //关闭
}
}
vue 单独页面定时器 离开页面销毁定时器
猜你喜欢
转载自www.cnblogs.com/xielisen/p/9509236.html
今日推荐
周排行