Vue3 router – view keep active:
<router-view v-slot="{ Component, route }">
<keep-alive :include="includeList">
<component
:is="Component"
:key="route.name"
v-if="includeList.includes(route.name)"
/>
</keep-alive>
<component
:is="Component"
:key="route.name"
v-if="(!includeList.includes(route.name) && !route.meta.keepAlive)"
/>
</router-view>
- First of all, make sure that the
include
passed value is the three forms in the official document: keep-alive - Make sure that the
<component>
corresponding component is definedname
(<script setup>
syntactic sugar cannot be definedname
, you need to change it to a non-syntactic sugar form, choose yourself)
Similar Posts:
- TypeError: Cannot read property ‘location‘ of undefined [How to Solve]
- Angular7:Can’t bind to ‘formGroup’ since it isn’t a known property of ‘form’ [Solved]
- Vue: How to use Vue-router in Axios
- Vue new page Jump [Three Method to Use]
- Uncaught SyntaxError: The requested module ‘/node_modules/.vite/react-router……Switch
- [Solved] VUE Project Error: Avoided redundant navigation to current location: “/XXX“
- [Solved] Vue router in the element UI navigation bar repeatedly clicks on the menu above version 3.0 and reports errors