// 模板中: <div class="home"> <keep-alive> <router-view v-if="$route.meta.keepAlive"></router-view> </keep-alive> <router-view v-if="!$route.meta.keepAlive"></router-view> </div> // 路由配置中: [ { path: 'main', name: 'main', component: main, meta: { keepAlive: false } // false为不缓存 }, { path: 'orderSearch', name: 'orderSearch', component: orderSearch, meta: { keepAlive: false } // false为不缓存 } ]
缓存与不缓存间可用:
如:从指定路由跳过来
watch: { '$route' (to, from) { if( from.path == "/home"){ //... } } }
.