【发布时间】:2019-06-02 06:21:12
【问题描述】:
我希望其他每一行都为灰色,但在以下示例中 - 所有行都变为灰色。
<table>
<tr v-for="i in item.env_vars" :style="{'background': index % 2 === 0 ? '#eee' : '#ccc' }">
<td> test1 </td>
<td> test2 </td>
<td> test3 </td>
</tr>
</table>
我在 vue 管理工具中看到了这个错误:
Property or method "index" is not defined on the instance but referenced during render.
我的代码有什么问题?
【问题讨论】:
-
如何创建多个
<tr>s?答案取决于此。您当前的代码只有一个<tr> -
这里没有for循环所以我不明白你从哪里得到
index
标签: javascript html css vue.js