TypeError: parentComponent.ctx.deactivate is not a function

使用Vue3的keep-alive时,没有配置key导致

TypeError: parentComponent.ctx.deactivate is not a function

于是我们在App.vue 中 keep-alive中添加配置,

<template>
  <div id="app">
    <router-view v-slot="{ Component }">
      <keep-alive>
        <component :is="Component" v-if="$route.meta.keepAlive" :key="$route.path"/>
      </keep-alive>
      <component :is="Component" v-if="!$route.meta.keepAlive"/>
    </router-view>
  </div>
</template>

问题得到解决

暂无评论

相关推荐

Vue中的select默认选中绑定条件

场景,我们要选择一个区域,0%到100%的一个区域,我们用了两个select来选择起始位和终止位,定义了一组数,0-10,直接 …

vue中的管道处理

我们经常用到管道,如linux命令下面,find和grep的管道处理等,在tp框架的模板里我们也使用到了管道来二次加工数据,在 …

微信扫一扫,分享到朋友圈

TypeError: parentComponent.ctx.deactivate is not a function