【发布时间】:2020-10-19 17:46:57
【问题描述】:
如果我在 v-if 中使用从 apollo 获取的数据(fetchPolicy:'cache-and-network'),它会抛出
vue.runtime.esm.js:619 [Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render.
<template>
<div
<div v-if="test">
{{ test }}
</div>
</div>
</template>
但如果我将它用作变量来渲染它就可以正常工作。
<template>
<div>
{{ test }}
</div>
</template>
实际使用的数据是对象,我需要有条件地渲染并通过 v-if 传递给另一个组件。
我曾尝试通过 get 获取数据,监视数据并手动设置它们,但最终一切都崩溃了。
关于评论:
如果我控制台 test 数据它将去 -> 服务器上的 true -> 客户端上的 false 然后再次在客户端上 true,如果我从 v-if 中删除 test 它会去:@服务器上的 987654331@ 和客户端上的 true
这与结构无关,在实际项目中它有一堆组件,如果数据没有在条件下使用它就可以正常工作
【问题讨论】:
-
服务器端的内容是什么样的?
-
我已经很久没有和 Nuxt 合作了,但是我看到这个问题仍然没有相关的答案。您身边的任何更新@Lukáš Gibo Vaic