vue3-keep-alive-component
A workaround solution for vue3 router&keep-alive components issue: keep-alive component in nested route result in child route mounted twice (https://github.com/vuejs/router/issues/626)
7,358
17
| Install | |
|---|---|
npm install vue3-keep-alive-component |
|
| Latest Version: | 1.0.19 |
| Vue: | 3 |
| License: | ISC |
| Last Updated: | Oct 13, 2023 |
| Links: | GitHub · npm |
Maintainer: emiyalee
Vue 3 Keep Alive Component
A workaround solution for vue3 router&keep-alive components issue keep-alive component in nested route result in child route mounted twice
Installation
npm i vue3-keep-alive-component -S
Usage
Keep Router Alive
<template>
<router-view v-slot="{ Component }">
<KeepAliveComponent :component="Component" />
</router-view>
</template>
<script lang="ts" setup>
import { KeepAliveComponent } from 'vue3-keep-alive-component'
</script>
<style></style>
Use Activated Route
When using <KeepAliveComponent/> and useRoute() together, there will be problem. In this case, use useActivatedRoute() instead.
import { useActivatedRoute } from 'vue3-keep-alive-component'
const activatedRoute = useActivatedRoute() // a replacement api for official api useRoute()
Building
- Clone this repo
- Make sure you have node-js
>=18.16 - Install dependencies
npm install - Run webpack dev server
npm run build
License
MIT License
Related Packages
vite-check-multiple-dom
Capture Vue runtime warnings and show actionable overlay in Vite dev.
28,604
vite-plugin-vue-transition-root-validator
Capture Vue runtime warnings and show actionable overlay in Vite dev.
12,551
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.19 | ^3.3.4 | ISC | |
| 1.0.18 | ^3.3.4 | ISC | |
| 1.0.17 | ^3.3.4 | ISC | |
| 1.0.16 | ISC | ||
| 1.0.14 | ISC | ||
| 1.0.13 | ISC | ||
| 1.0.11 | ISC | ||
| 1.0.10 | ISC | ||
| 1.0.8 | ISC | ||
| 1.0.7 | ISC | ||
| 1.0.6 | ISC | ||
| 1.0.5 | ISC | ||
| 1.0.4 | ISC | ||
| 1.0.3 | ISC | ||
| 1.0.2 | ISC | ||
| 1.0.1 | ISC | ||
| 1.0.0 | ISC |