第一种:
<template> <keep-alive> <router-view v-if="$route.meta.keepAlive"></router-view> </keep-alive> <router-view v-if="!$route.meta.keepAlive"></router-view> </template>
router 加上配置
meta: {
keepAlive: true // false
}
第二种:
<keep-alive exclude="goodsEdit,adEdit"> <router-view></router-view> </keep-alive> include属性表示只有name属性为goodsEdit,adEdit的组件会被缓存, 注意是组件的name, 还有就是逗号后面不能空格(填坑)
参见:https://www.cnblogs.com/Mr-Rshare/p/10729497.html