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
vite-plugin-vue-routes

File-based routing for Vue applications using Vite.

1,924 1
vue-router-tiny

A router for Vue.js

562 3

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