uniAPP中使用页面嵌套页面destroyed无法触发时

689 阅读1分钟

遇到页面嵌套destroyed无法触发删除定时器,可以使用监听路由方式

data() {
    return {
        timer_interval: null,
    }
},
watch: {
    $route(){
        console.log("成功!")
        let that = this;
        clearInterval(that.timer_interval);
        that.timer_interval = null;
    }
},
destroyed() {
    console.log(" destroyed ") //  失效
}