【发布时间】:2020-05-13 20:40:46
【问题描述】:
我正在尝试使用 Vue.js 和 Nuxt 在表中循环一个 tr。但是当我加载页面时出现以下错误
vue.runtime.esm.js?2b0e:619 [Vue 警告]:客户端渲染 虚拟 DOM 树与服务器呈现的内容不匹配。这是 可能是由不正确的 HTML 标记引起的,例如嵌套
内的块级元素,或缺少 .百灵补水 并执行完整的客户端渲染。
当我从我的 HTML 中的以下代码块中删除表格时,错误消失了。这怎么可能发生?我检查了所有结束标签,它们似乎是匹配的。这里发生了什么?
在模板中
<template>
<ContentBlock id="statistics" class="content-light">
<div class="content-grid-light">
<div class="content-grid-item-1">
<div>
<table class="table">
<tr v-for="(statistic, index) in statistics" :key="index" :value="statistic">
<th class="table-cell">{{statistic.key}}</th>
<td class="table-cell statistic-value">{{statistic.value}}</td>
</tr>
</table>
</div>
</div>
</div>
</ContentBlock>
</template>
在脚本中
data(){
return{
statistics: [
{key:"TestKey1", value:"TestValue1"},
{key:"TestKey2", value:"TestValue2"},
{key:"TestKey3", value:"TestValue3"},
{key:"TestKey4", value:"TestValue4"},
],
}
},
这是我渲染的 html
【问题讨论】: