data: {
    return {
        timer: null
    }
},
created() {
    this.timer = setInterval(....);
},
beforeDestroy() {
    if(this.timer) { //如果定时器还在运行 或者直接关闭,不用判断
        clearInterval(this.timer); //关闭
    }
}

Logo

前往低代码交流专区

更多推荐