Commit 1f8638e6 by caoyanzhi

update: keep alive优化

parent 5dd255d6
...@@ -205,11 +205,11 @@ const router = new Router({ ...@@ -205,11 +205,11 @@ const router = new Router({
}) })
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const { keepAlive, componentName, fromPath } = to.meta || {}; const { keepAlive, componentName, fromPath } = to.meta || {};
if (keepAlive && fromPath.every(el => el != '/')) { if (keepAlive && Array.isArray(fromPath) && fromPath.every(el => el != '/')) {
fromPath.push('/'); fromPath.push('/');
} }
// 当前路径的keepAlive为true而且from.path不在fromPath中时,将清除to.path的缓存 // 当前路径的keepAlive为true而且from.path不在fromPath中时,将清除to.path的缓存
if (keepAlive && fromPath.every(el => el != from.path)) { if (keepAlive && Array.isArray(fromPath) && fromPath.every(el => el != from.path)) {
delCache(router.apps, componentName); delCache(router.apps, componentName);
} }
next(); next();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment