data(){
return {
timerFun:function(){
},}
}
created(){
this.getData();// 上来先请求一次
this.timer();// 再去执行定时任务
},
methods: {
getData() {
... },
timer() {
this.timerFun = setInterval(() => {
this.getData();
},3000)
}
}
}
beforeDestroy() {
clearInterval(this.timerFun);
},
vue实现一个定时器刷新任务
猜你喜欢
转载自blog.csdn.net/qq_42931285/article/details/124996449
今日推荐
周排行