vue 单独页面定时器 离开页面销毁定时器
data: {return {timer: null}},created() {this.timer = setInterval(....);},beforeDestroy() {if(this.timer) { //如果定时器还在运行 或者直接关闭,不用判断clearInterval(this.timer); //关闭}}...
·
data: {
return {
timer: null
}
},
created() {
this.timer = setInterval(....);
},
beforeDestroy() {
if(this.timer) { //如果定时器还在运行 或者直接关闭,不用判断
clearInterval(this.timer); //关闭
}
}
更多推荐
已为社区贡献25条内容
所有评论(0)