解决Vue 后台管理平台离开页面清除定时器失效问题
砥砺者一号:
![表情包](https://g.csdnimg.cn/static/face/emoji/054.png) beforeRouteLeave (to, from, next)不触发:
建议添加如下程序:
destroyed(){
console.log("我离开了")
window.clearInterval(this.timer1);
window.clearInterval(this.timer2);
window.clearInterval(this.timer3);
window.clearInterval(this.timer4);
},
注意:
1、destroyed()与mounted()和methods()同级函数三个并列
destroyed(){
},
mounted(){
,
methods(){
}
2、timer1、timer2、timer3、timer4四个为定时器函数id:
this.timer1 = setInterval(() => { ...
this.timer2 = setInterval(() => { ...
this.timer3 = setInterval(() => { ...
this.timer4 = setInterval(() => { ...
我程序用到4个定时器,都在data中定义
data: () => ({
timer1: null,
timer2: null,
timer3: null,
timer4: null,
}因此函数id为this.timer1
希望对大家有帮助,我也小白,好不容易解决的定时器关闭问题
解决Vue 后台管理平台离开页面清除定时器失效问题
砥砺者一号:
beforeRouteLeave (to, from, next)不触发,不生效如何解决呢
echarts报错: Can‘t get DOM width or height. Please check dom.clientWidth and dom.c
wavyhair_:
可以的小老弟
Vue获取下拉框的选中值以及下标
qq_67740814:
温馨提醒
Vue获取下拉框的选中值以及下标
qq_67740814:
看清楚原生可以获取到,不行的
|