首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Vue 3中的SSR和keep-alive问题:动态组件

Vue 3中的SSR和keep-alive问题:动态组件
EN

Stack Overflow用户
提问于 2021-08-23 04:44:39
回答 1查看 350关注 0票数 3
代码语言:javascript
运行
复制
<template>
      <div class="default-layout">
          <router-view v-slot="{ index }">
            <keep-alive>
              <component :is="index" :key="route.fullPath" />
            </keep-alive>
          </router-view> 
      </div>
</template>
    
<script lang="ts">
    import { defineComponent} from "vue";
    import { useRoute } from "vue-router";
    import Index from "@/pages/index";
    
    export default defineComponent({
      name: "app",
      components: {
        Index,
      },
      setup: () => {
        const route = useRoute();
       
        return { route, index: Index };
      },
    });

</script>

渲染时会出现错误:

代码语言:javascript
运行
复制
[Vue warn]: Hydration node mismatch:
- Client vnode: Symbol(Comment) 
- Server rendered DOM: <!--[--> (start of fragment) 
  at <KeepAlive> 
  at <RouterView key=0 > 
  at <App>

Hydration children mismatch in <div>: server rendered element contains fewer child nodes than client vdom. 

Hydration completed but contains mismatches.

我应该做些什么来解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2021-11-16 13:43:04

我相信这是个bug。你可以在https://github.com/vuejs/vue-next/issues/4817上关注它

在撰写本文时,Vue的维护者还没有证实这一点。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68887411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档