【发布时间】:2019-10-29 15:22:49
【问题描述】:
我无法理解为什么会这样!所以,这段代码:
<div class="container">
<div class="row" v-for="rows in data.Rows"> {{ rows }} </div>
</div>
将渲染对象中的所有行。 但是,当我在表中使用相同的语法时:
<table>
<tr v-for="rows in data.Rows"> {{ rows }} </tr>
</table>
我得到错误:
[Vue warn]: Property or method "rows" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
为什么在表格中使用这样的 v-for 会出现问题?我想要一个表格来显示数据,因为它更适合这种情况下的目的。否则我会选择 div 而不是表格行,但我希望它能够正常工作。关于为什么会发生这种情况的任何想法?
【问题讨论】:
-
这个模板在哪里?它是直接在 HTML 文件中吗?
-
能否用 row.Rows 中的示例对象更新问题?