vue 切换页面setInterval问题

vue 是单页面应用,路由切换后,定时器并不会自动关闭,需要手动清除,当页面被销毁时,清除定时器即可。

mounted(){
     clearInterval(this.timer);
     this.setTimer();
    },
destroyed(){
    clearInterval(this.timer)
  }

猜你喜欢

转载自blog.csdn.net/zhengyinling/article/details/84565379