由于单页面应用路由地址变更页面不会刷新,定时器一直会存在,页面组件销毁时要清除

const timer = setTimeout(() => {
   this.fn()            
}, 3000);
this.$once('hook:beforeDestroy', () => {
    clearInterval(timer );
})
//或
this.timer = setTimeout(() => {
   this.fn()            
}, 3000);

destroyed(){
clearInterval(this.timer );
}

 

Logo

前往低代码交流专区

更多推荐