vue 缓存界面

1.配置路由
meta: {
 keepAlive: true
}
 
2.配置App.vue
<keep-alive>
  <router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
 
3.加载时执行
activated() {}
 
4.后台时执行
deactivated() {}
 
原文地址:https://www.cnblogs.com/xiaolinxitong/p/13140535.html