25 lines
654 B
JavaScript
25 lines
654 B
JavaScript
// 定时刷新
|
|
const intervalUpdate= {
|
|
data: function () {
|
|
return {
|
|
intervalUpdateTimer:null
|
|
}
|
|
},
|
|
beforeDestroy() {
|
|
console.log('销毁之前 清空定时器')
|
|
if( this.intervalUpdateTimer) {
|
|
window.clearInterval(this.intervalUpdateTimer)
|
|
this.intervalUpdateTimer = null
|
|
}
|
|
},
|
|
methods:{
|
|
updateInterval: function (cn,time=60000) {
|
|
window.clearInterval(this.intervalUpdateTimer)
|
|
this.intervalUpdateTimer = null
|
|
this.intervalUpdateTimer = window.setInterval(cn,time)
|
|
}
|
|
}
|
|
|
|
}
|
|
export default intervalUpdate
|