vue 3.0 keep-alive 失效 报错 Cannot read properties of null (reading ‘parentNode‘)

版本:
vue “3.2.4”
vue-loader “16.4.1”
vue-router “4.0.11”

 <router-view v-slot="{ Component }">
       <keep-alive>
          <suspense timeout="0">
            <template #default>
              <component :is="Component" />
            </template>
            <template #fallback>
            ...
            </template>
          </suspense>     
        </keep-alive>
      </router-view>

报错
vue 3.0 keep-alive 失效 报错 Cannot read properties of null (reading ‘parentNode‘)_第1张图片
解决方法:

 <router-view v-slot="{ Component }">
       <keep-alive :include="includeList"> //添加include属性  解决了失效问题
          <suspense timeout="0">
            <template #default>
              <component :is="Component" />
            </template>
            <template #fallback>
            ....
            </template>
          </suspense>     
        </keep-alive>
      </router-view>

*可能是新版本的问题,也有可能是文档上有提示我没看到,先记录一下,晚点看看原理

你可能感兴趣的:(vue,vue.js,javascript,前端)