data () {
return {
timer : null
}
},
beforeDestroy () {
let that = this;
clearInterval(that.timer);
that.timer = null;
},
destroyed () {
let that = this;
clearInterval(that.timer);
that.timer = null;
},
mounted () {
let that = this;
that.timer = window.setInterval(() => {
setTimeout(() => {
that.getData()
}, 0)
},1000)
},
原文:https://www.cnblogs.com/chenzhengyang/p/15099877.html