Vue在两个v-for级别获得$ index

时间:2016-08-22 08:36:21

标签: vue.js

这是一张Vue表。

<table>
    <tr v-for="height in chartHeight" track-by="$index">
        <td class="item" v-for="width in chartWidth" track-by="$index">
            index of row and column here
        </td>
    </tr>
</table>

高度$index被宽度内部覆盖。如何访问$index

1 个答案:

答案 0 :(得分:2)

<table>
    <tr v-for="(hid, height) in chartHeight" track-by="hid">
        <td class="item" v-for="(wid, width) in chartWidth" track-by="wid">
            {{ hid }}, {{ wid }}
        </td>
    </tr>
</table>