关于keep-alive在vue2和vue3的写法及警告

211 阅读1分钟

vue2中的写法

<keep-alive>
    <router-view />
</keep-alive>

vue3z中的写法

<router-view v-slot="{ Component }">
      <keep-alive>
        <component :is="Component" />
      </keep-alive>
</router-view>

在vue3中写了vue2的语法警告信息如下

image.png