VUE定时任务 vue定时器 vue定时器 使用该方法,切换路由不会继续监听,只在本页面监听 mounted() { this.buttonInit(); const timer = setInterval(() =>{ console.log("定时器") }, 1000); // 在beforeDestroy钩子触发时清除定时器 this.$once('hook:beforeDestroy', () => { clearInterval(timer); }) }