Skip to content

3级路由缓存问题 #3116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed

3级路由缓存问题 #3116

wants to merge 10 commits into from

Conversation

dingangang
Copy link
Contributor

根本原因: 3级路由根文件的name不会被添加到state.tagsView.cachedViews中。
解决方法:在3级路由根页面即本例的\nested\menu1\index.vue中的created方法内,将根页面的名称加入到state.tagsView.cachedViews(组件的name需要和路由的name保持一致)。这样3级路由页面就可以进行缓存,并且更深层级如menu1-2-1也可以进行缓存。
仅提供了一个思路,如果有更好的方法解决是最好了。

dingangang and others added 6 commits April 18, 2019 12:32

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
fix win7 win10 path

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
merge base

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
merge from origin master

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
merge from panjiachen
访问3级路由时,3级根路由的名称不会存入state.tagsView.cachedViews中,所以3级路由页面不会缓存。
找到了一种解决方案:
在3级路由根页面即本例的\nested\menu1\index.vue中的created方法内,将根页面的名称加入到state.tagsView.cachedViews。这样3级路由页面就可以进行缓存,并且更深层级如menu1-2-1也可以进行缓存。
@netlify
Copy link

netlify bot commented Apr 15, 2020

Deploy preview for vue-element-admin processing.

Building with commit be527bc

https://app.netlify.com/sites/vue-element-admin/deploys/5ecb8c4ad9d3d80008f50862

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
merge
@shengxiaoliang
Copy link

@dingangang 按照你的方法,三级路由缓存了,但是点击刷新,清除不了缓存 大佬能帮忙看看

@shengxiaoliang
Copy link

Deploy preview for vue-element-admin ready!

Built with commit 0f0f69a

https://deploy-preview-3116--vue-element-admin.netlify.app

image
刷新不清除缓存

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
merge master
@dingangang
Copy link
Contributor Author

Deploy preview for vue-element-admin ready!
Built with commit 0f0f69a
https://deploy-preview-3116--vue-element-admin.netlify.app

image
刷新不清除缓存

tagsView.js

addCachedView({ commit }, view) {
if (view.matched && view.matched.length >= 3) {
commit('ADD_CACHED_VIEW', view.matched[1])
}
commit('ADD_CACHED_VIEW', view)
},

delCachedView({ commit, state }, view) {
return new Promise(resolve => {
if (view.matched && view.matched.length >= 3) {
commit('DEL_CACHED_VIEW', view.matched[1])
}
commit('DEL_CACHED_VIEW', view)
resolve([...state.cachedViews])
})
},

修改这两个方法可以解决。但是我感觉解决方法有点取巧了。你可以在项目里试试。

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Revert "merge master"
@strivezc
Copy link

strivezc commented Dec 3, 2020

点击刷新一个页面后,其他相同层级的三级菜单也会一起被刷新了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants