반응형
Vue 중첩 v-for, 상위 인덱스 가져오기
나는 내포되어 있다.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
하지만 여전히 효과가 없어오류는 없지만 데이터도 없다.내가 어떻게 해야 그 물건을 얻을 수 있을까?index
내 부모님한테 무슨 일이요?
다른 이름으로 다른 인덱스를 정의하거나 첫 번째 인덱스의 이름을parent_index
<template v-for="(branch, parent_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>
참조URL: https://stackoverflow.com/questions/52902752/vue-nested-v-for-get-index-of-parent
반응형
'Programing' 카테고리의 다른 글
구성 요소로 전달된 v-data를 소품으로 편집하는 Vue (0) | 2022.03.06 |
---|---|
TypeError: this.getOptions는 함수가 아님 (0) | 2022.03.06 |
반응 JS - 검색되지 않은 TypeError: this.props.data.map은 함수가 아님 (0) | 2022.03.06 |
VSCode에서 jsx 자동 들여쓰기 방법 (0) | 2022.03.06 |
vue 구성 요소에서 양식을 제출할 때 값 라디오 버튼을 얻는 방법 (0) | 2022.03.06 |