在写个小项目,其中前端页面切换后,之前页面的定时器依然不停的往后台发请求。担心数据库的连接隐患,于是切换页面后,让定时器停止。
mounted() {
this.timeBatch = setInterval(() => {
this.pageUpdate();
}, 10000);
}
destroyed() {
clearInterval(this.timeBatch)
},
完美实现。
在写个小项目,其中前端页面切换后,之前页面的定时器依然不停的往后台发请求。担心数据库的连接隐患,于是切换页面后,让定时器停止。
mounted() {
this.timeBatch = setInterval(() => {
this.pageUpdate();
}, 10000);
}
destroyed() {
clearInterval(this.timeBatch)
},
完美实现。