vue-router中keep-alive的使用以及注意情况
1. 使用+ 在app.vue中用keep-alive将router-view包裹起来<keep-alive><router-view v-if="$route.meta.keepAlive"></router-view></keep-alive><ro
·
1. 使用
+ 在app.vue中用keep-alive将router-view包裹起来
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
+ 在router.js中处理
{
path: '/foodDeal/info',
component: resolve => require(['@/views/foodDeal/info'], resolve),
meta: { keepAlive: false }
},
注意: 缓存的页面钩子失效,必须使用activated和deactivated
activated() {
// 显示
console.log(1);
},
deactivated() {
// 不显示
console.log(2);
},
更多推荐
已为社区贡献16条内容
所有评论(0)