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

使用keepAlive缓存路由,首次跳别的路由时候,被缓存的路由会执行unmounted方法 #3648

Closed
MsBaiYi opened this issue Apr 22, 2021 · 4 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: keep-alive

Comments

@MsBaiYi
Copy link

MsBaiYi commented Apr 22, 2021

Version

3.0.11

Reproduction link

https://github.com/MsBaiYi/oneBug

Steps to reproduce

  1. 启动脚手架,打开F12 console
  2. 点击缓存Home页面,使include为 ['Home']
  3. 点击 count 按钮, 使count不为 0
  4. 切换路由为about,在console中观察到打印 'home 销毁',说明触发了 unmounted
  5. 切换回home,未打印'home 创建'且count不为0,说明home是被缓存的,与第4步触发unmounted现象发生矛盾

What is expected?

期望被缓存的路由不执行销毁生命周期函数 (unmounted)

What is actually happening?

被缓存的路由组件首次跳别的路由会执行销毁生命周期函数


遇到这个bug的场景是添加面包屑功能,在面包屑存在的路由需要被缓存,关闭面包屑的路由组件应被释放

@HcySunYang HcySunYang added 🐞 bug Something isn't working 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: keep-alive labels Apr 22, 2021
@haoziqaq
Copy link

请问这个问题在Vue的正式版本中修复了么?我在查阅更新日志的过程中没有搜索到相关的信息

@edison1105
Copy link
Member

@haoziqaq 还没有,PR 还是 open 的呢。

@haoziqaq
Copy link

谢谢~

@liu-yan-liang
Copy link

现在还没有解决嘛?怎么久了

iwusong pushed a commit to iwusong/core that referenced this issue May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: keep-alive
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants