App.vue
<keep-alive> <router-view v-if="$route.meta.keepAlive"></router-view> </keep-alive> <router-view v-if="!$route.meta.keepAlive"></router-view>
Index.js路由
list
{ path: '/list', name: 'list', component: List, meta: { requiresAuth: true, privilege: ['capacityStatus'], keepAlive: true,//此组件需要被缓存 isBack: false, //用于判断上一个页面是哪个 } }
details
{ path: '/details', name: 'details', component: Details, meta: { requiresAuth: true, privilege: ['capacityStatus'], } }