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 include not working for async loaded components #3529

Closed
rbonsall-turnto opened this issue Apr 2, 2021 · 2 comments · Fixed by #3531
Closed

keep-alive include not working for async loaded components #3529

rbonsall-turnto opened this issue Apr 2, 2021 · 2 comments · Fixed by #3531
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

@rbonsall-turnto
Copy link

Version

3.0.11

Reproduction link

https://github.com/rbonsall-turnto/async-keep-alive-example

Steps to reproduce

In the example, there are 3 tabs that switch between components wrapped in a <keep-alive> with an include for 2 of the components.

  1. HelloWorld.vue - not loaded async, listed in keep-alive include
  2. HelloWorldAsync.vue - loaded async, listed in keep-alive include
  3. GoodbyeWorldAsync.vue - loaded async, but not listed in keep-alive include

In each tab there is a button to up the count. Click the button in each tab to establish a state change for each component. The number of the count displays in the button.

What is expected?

The 2 components that are in the keep-alive include should main their state when switching between tabs.

  • HelloWorld.vue
  • HelloWorldAsync.vue

The GoodbyeWorldAsync.vue component is not in the include so it should not maintain its state.

What is actually happening?

The HelloWorldAsync.vue component does not maintain its state as expected.

Whereas, the HelloWorld.vue non-async component does maintain its state as expected.


This worked in Vue 2. I discovered the issue after migrating a project to Vue 3.

Interestingly, if the "include" is removed from the <keep-alive>, all 3 components maintain their state as expected. So, it appears to work for async components, just not when listed in the <keep-alive> "include".

@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 2, 2021
@chaimHL
Copy link

chaimHL commented Aug 23, 2022

I encountered this problem again in version 3.27
我在3.27版本也遇到这个问题了

@anhchangvt1994
Copy link

@yyx990803 I still encountered this problem again in version 3.x latest

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.

4 participants