From 4537e5185dc7a0cd0eb1b5eedba5aaed7eb6b649 Mon Sep 17 00:00:00 2001 From: hooray <304327508@qq.com> Date: Fri, 15 Oct 2021 13:53:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=90=8E=E7=BD=AE=E9=92=A9?= =?UTF-8?q?=E5=AD=90=E9=87=8C=E4=BB=A3=E7=A0=81=E7=B2=BE=E7=AE=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 6139c0c2..d1b3f799 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -214,11 +214,7 @@ router.afterEach((to, from) => { if (to.meta.cache) { let componentName = to.matched[to.matched.length - 1].components.default.name if (componentName) { - to.matched.forEach(item => { - if (item.components.default.name && item.components.default.name != 'Layout') { - store.commit('keepAlive/add', item.components.default.name) - } - }) + store.commit('keepAlive/add', componentName) } else { console.warn('该页面组件未设置组件名,会导致缓存失效,请检查') }