Skip to content

Commit

Permalink
refactor(router): 组件默认开启缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
yulimchen committed Feb 24, 2021
1 parent e922136 commit f0082ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,19 @@ const routes = [
{
path: '/demo',
name: 'Demo',
component: () => import('@/views/demo'),
meta: {
keepAlive: true
}
component: () => import('@/views/demo')
},
{
path: '/tools',
name: 'Tools',
component: () => import('@/views/tools'),
meta: {
keepAlive: true
}
component: () => import('@/views/tools')
},
{
path: '/about',
name: 'About',
component: () => import('@/views/about'),
meta: {
keepAlive: false
noCache: true
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/cachedView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const mutations = {
ADD_CACHED_VIEW: (state, view) => {
// 不重复添加
if (state.cachedViews.includes(view.name)) return
if (view?.meta?.keepAlive) {
if (!view?.meta?.noCache) {
state.cachedViews.push(view.name)
}
},
Expand Down

0 comments on commit f0082ec

Please sign in to comment.