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

keep-alive缓存会造成子路由重复渲染 #67

Closed
RanMaoting opened this issue Oct 22, 2021 · 7 comments
Closed

keep-alive缓存会造成子路由重复渲染 #67

RanMaoting opened this issue Oct 22, 2021 · 7 comments

Comments

@RanMaoting
Copy link

RanMaoting commented Oct 22, 2021

你好,请教一下,最新版使用了keep-alive的页面生命周期会加载多次,导致页面重复请求,这种怎么解决呢

@xiaoxian521
Copy link
Member

你好,请教一下,最新版使用了keep-alive的页面生命周期会加载多次,导致页面重复请求,这种怎么解决呢

提供个例子吧

@xiaoxian521 xiaoxian521 added the needs more info 需要更多信息 label Oct 22, 2021
@RanMaoting
Copy link
Author

就现在的线上demo多级路由那一块,menu1-2-2路由keepAlive改为false,页面加上生命周期就可以发现他们被执行了多次

@xiaoxian521
Copy link
Member

ok 我会检查它

@xiaoxian521 xiaoxian521 added Community::Bug Report 🔨 bug and removed needs more info 需要更多信息 labels Oct 22, 2021
@RanMaoting
Copy link
Author

这个bug似乎跟vue-router有关,当vue-router和keep-alive一起使用,同时嵌套子路由的话就会触发

@Cleam
Copy link

Cleam commented Oct 26, 2021

目前解决这个问题的一个办法是在嵌套路由的场景下,不使用 KeepAlive 包裹 RouterView (答案来自下面文章)

这个bug暂时貌似无更好的解决办法,可以看看这里:

@xiaoxian521
Copy link
Member

xiaoxian521 commented Dec 12, 2021

fix: d57e0e3

@anyshift
Copy link

一级 router-view 设置成 <component :is="Component" :key="undefined"/> 后临时解决了困恼好多天的问题,不过还是期待 vue-router 官方能给出更好的解决办法

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

No branches or pull requests

4 participants