Skip to content
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

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

Open
yellowfish621 opened this issue Sep 26, 2024 · 2 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

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

1 participant