【发布时间】:2018-10-20 05:36:16
【问题描述】:
我有一个嵌套的v-for,基本上,我想获取父级v-for 的索引并在子级v-for 内部使用它
<template v-for="(branch, index) in $store.state.agency.branch_users.users">
<table class="table" id="agency-contact-table" >
<thead>
<tr>
<th aria-colindex="1" class="">#</th>
<th aria-colindex="1" class="">Name</th>
</tr>
</thead>
<tbody>
<tr v-if="branch.role_users" v-for="(branch_users, index) in branch.role_users">
<td>{{$parent.$index}}</td>
<td>{{branch_users.user.first_name}} {{branch_users.user.last_name}}</td>
</tr>
</tbody>
</table>
</template>
我尝试使用$parent.$index,但它仍然不起作用。它没有显示任何错误,但也没有数据。
我应该怎么做才能在我的父母 v-for 中获得index?
【问题讨论】: