vue 单独页面定时器 离开页面销毁定时器

it2022-05-05  91

data: { return { timer: null } }, created() { this.timer = setInterval(....); }, beforeDestroy() { if(this.timer) { //如果定时器还在运行 或者直接关闭,不用判断 clearInterval(this.timer); //关闭 } }

转载于:https://www.cnblogs.com/xielisen/p/9509236.html


最新回复(0)