vue路由改变后,计时器依然在执行的解决方法

在a页面中定义了一个计时器,跳转到b页面的时候发现a页面的计时器依然在执行,解决方法:在a页面的beforeDestroy生命周期里停止定时器即可!
代码如下:
mounted() { this.getSize=setInterval(() => { //定时器 执行的内容 },100)}
beforeDestroy(){ clearInterval(this.getSize); },
版权声明:
作者:东明兄
链接:https://blog.crazyming.com/note/588/
来源:CrazyMing
文章版权归作者所有,未经允许请勿转载。


共有 0 条评论