Subscribe on changes!

keep-alive嵌套缓存,组件onMounted多次执行

avatar
Apr 19th 2022

Version

3.2.25

Reproduction link

github.com

Steps to reproduce

npm install npm run dev keep-alive缓存列表,点击跳转详情页,onMounted钩子函数执行数次

What is expected?

执行一次

What is actually happening?

执行数次

WechatIMG171 WechatIMG172
avatar
Apr 19th 2022

Your key always change. You might want to use

    <router-view v-slot="{ Component, route }">
      <transition mode="out-in" name="fade">
        <keep-alive :include="cachedViewsDeep">
          <component :is="Component" :key="route.name || route.path" />
        </keep-alive>
      </transition>
    </router-view>

Remember to use the forum or the Discord chat to ask questions!

avatar
Apr 20th 2022

Your key always change. You might want to use

    <router-view v-slot="{ Component, route }">
      <transition mode="out-in" name="fade">
        <keep-alive :include="cachedViewsDeep">
          <component :is="Component" :key="route.name || route.path" />
        </keep-alive>
      </transition>
    </router-view>

Remember to use the forum or the Discord chat to ask questions!

forum

avatar
May 17th 2022

我也遇到了 你是怎么解决的