Using vue_2.20
v-for loop, the key value of the parent loop needs to be obtained in the sub-loop,
The data structure is as follows
data:{
key1:[
{a:'x',b:'y'},
{a:'x',b:'y'}
],
key2:[
{a:'x',b:'y'},
{a:'x',b:'y'}
]
}
<p v-for="(value, key, index) in data">
<p v-for="(value_c, key_c, index_c) in value" onclick="vm.getmydata(key,key_c)"></p>
</p>
The inner layer wants to click to get the corresponding parent key and child index, so as to obtain the information corresponding to p.
Okay, I found the problem, just replace onclick with v-on:click binding event -=
Loop data? And it’s still an object