如果我'cache-and-network'在 v-if 中使用从 apollo 获取的数据(fetchPolicy:),它会抛出
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>
Run Code Online (Sandbox Code Playgroud)
但如果我将它用作变量来渲染它就可以正常工作。
<template>
<div>
{{ test }}
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
实际使用的数据是对象,我需要有条件地渲染并使用 v-if 传递给另一个组件。
我尝试过通过 get 获取数据、监视数据并手动设置它们,但最终一切都崩溃了。
关于评论:如果我控制台test数据,它将转到 ->true在服务器上 ->false在客户端上,然后true …