data: {return {timer: null}},created() {this.timer = setInterval(....);},beforeDestroy() {if(this.timer) {//如果定时器还在运行 或者直接关闭,不用判断clearInterval(this.timer); //关闭}}
1200字范文,内容丰富有趣,写作的好帮手!
时间:2020-11-18 18:57:50
data: {return {timer: null}},created() {this.timer = setInterval(....);},beforeDestroy() {if(this.timer) {//如果定时器还在运行 或者直接关闭,不用判断clearInterval(this.timer); //关闭}}