vue3 keep-alive not working
See original GitHub issueWhat happened?
I tried two ways:
<template>
<!-- <router-view /> -->
<router-view v-slot="{ Component }">
<keep-alive>
<component :is="Component" :key="$route.name" v-if="$route.meta.keepAlive"></component>
</keep-alive>
<component :is="Component" v-if="!$route.meta.keepAlive" :key="$route.name"></component>
</router-view>
</template>
AND
<template>
<!-- <router-view /> -->
<router-view v-slot="{ Component }">
<keep-alive include="xxx,bbb">
<component :is="Component" :key="$route.name"></component>
</keep-alive>
</router-view>
</template>
keep alive not working, created/unmounted is always called. What’s wrong with it?
What did you expect to happen?
The keepalive component should be cached and not refreshed
Reproduction URL
Use keep-alive by document
How to reproduce?
Use keep-alive by document
Flavour
Quasar CLI with Webpack (@quasar/cli | @quasar/app-webpack)
Areas
Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)
Platforms/Browsers
No response
Quasar info output
Dev mode.......... spa
Pkg quasar........ v2.6.6
Pkg @quasar/app... v3.3.3
Pkg webpack....... v5
Debugging......... enabled
Configured browser support (>= 86.50% of global marketshare):
· Chrome for Android >= 100
· Firefox for Android >= 99
· Android >= 100
· Chrome >= 91
· Edge >= 97
· Firefox >= 90
· iOS >= 12.2-12.5
· Opera >= 79
· Safari >= 13.1
Relevant log output
No response
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Vue.js <keep-alive> in template for slot not working
The issue we're having is that the <keep-alive> is not working. Every time you go back or forth in the steps the component...
Read more >[vue 3] keep-alive lifecycle issue - Get Help
Hello, I have a nested router-view in a keep-alive element. ... The double mounting seems to be causing performance issues, it takes twice ......
Read more >vue-router-keep-alive-helper - npm
Auto destroy keepAlive components when go back. Latest version: 0.1.0, last published: 3 months ago.
Read more >Caching your Dynamic components with Vue Keep-Alive
While it's useful in most cases, there are times when we want to save the cached state of a hidden element. Vue keep-alive...
Read more >An Overview of Vue Keep-Alive - LearnVue
When working with dynamic components, Vue recreates new instances of ... a definitive answer on when/when not to use keep-alive components.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
Don’t think there’s something that needs configured for this to work. However, all things that can be configured are here.
Copy-pasting stuff from the “net” without understanding them is not really a good way to make progress. This ticket should at best be a post in our forum requesting help from the community.
But bottom line, this has nothing to do with Quasar but with Vue exclusively (if even). The right approach to report a Vue ticket is to their repo, not ours.
Thanks.
@cozumel424 please make a codepen