Tag Archives: The vue3 router view remains included

Vue3 router view keep alive include does not work [How to Solve]

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>
  1. First of all, make sure that the includepassed value is the three forms in the official document: keep-alive
  2. Make sure that the <component>corresponding component is defined name<script setup>syntactic sugar cannot be defined name, you need to change it to a non-syntactic sugar form, choose yourself)