Skip to content

deepClone router中asyncRoutes 导致每次点击侧边栏,layout组件都重新渲染 #4254

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

Open
yellowfish621 opened this issue Sep 26, 2024 · 3 comments

Comments

@yellowfish621
Copy link

我的项目是从后端传router的key去和前端路由表中asyncRoutes的name做匹配,最后过滤生成新路由表,
所以我修改了store中的generateRoutes方法 使用deepClone(asyncRoutes)
image

但是不知为何导致生成的路由每次点击侧边栏,Layout组件都会重新渲染一次
而当我执行logout退出登录,再重新登录后,Layout组件却可以只渲染一次了,令人十分不解

@yellowfish621
Copy link
Author

我暂时想到的是使用了deepClone导致Layout原本是共同的父组件变成了不同的组件 但是为什么退出后重新登录一下这个问题就解决了 明明重新登录也使用了deepClone重置路由

@yellowfish621
Copy link
Author

解决了,我在genRoutes方法所在的文件里重新引入了一下Layout
image
然后手动给每个路由赋值了一下同一个Layout
image

@yxk17668
Copy link

侧边栏本地运行正常,发版显示就异常,页面刷新之后,class自动刷新为
class="app-wrapper hideSidebar withoutAnimation mobile",hideSidebar withoutAnimation mobile属性为异常添加
且浏览器cookie 中sidebarStatus被强制刷新 赋值0
目前排查怀疑1、页面路由(本地运行正常)2、Nginx代理(Https)异常导致cookie失效
求解!
Image

Image

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

No branches or pull requests

2 participants