该钩子函数配合keep-alive来使用,使用了keep-alive就不会调用beforeDestory和destoryed钩子了,因为组件没有被销毁,而是被缓存起来了,所以deactivated钩子可以看做是beforeDestory和destoryed的替代。
activated(){
//页面且回来的时候会触发 类似于 created
//方法的操作
}
deactivated() {
//等同于 销毁的生命周期
console.log("切换出发了3");
window.clearInterval(this.timers);
this.timers = null;
},```