keep-alive
例如A,B页面,A页面开启keepAlive,B返回A的时候时缓存的,但有时需要B返回A时取消A的keepAlive缓存。
这时候需要在A页面添加以下代码:
{
name: 'B', //给B路由添加一个name名字
path: '/B',
component: (resolve) => require(['../components/susseccPage.vue'], resolve),
meta: {
title: '发布成功'
}
},
beforeRouteEnter(to, from, next) { //在进入A路由前
if (from.name == "B" && /labelStr/.test(window.location.href) ) { //判断页面是从B过来的,且添加了一些参数
to.meta.keepAlive = false;
}
next();
},