问题提出背景:echarts
的图层必须要定时刷新,一分钟或者5分钟向接口重新获取数据。
data() {
return {
timer: null
}
},
created() {
this.timer = setInterval(()=>{
this.getUserCover() //一分钟调用接口一次
},60000)
}
destroyed() {
clearInterval(this.timer) // 可以判断如果定时器还在运行就关闭 或者直接关闭
}