vue3 router-view keep-alive include 不生效問題解決


vue3 的 router-view keep-alive寫法:

 <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. 首先確保include傳的值為官方文檔中的三種形式:keep-alive
  2. 確保<component>對應的組件里面定義了name(<script setup>語法糖無法定義name,需改成非語法糖形式,自己取舍吧)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM