Home  >  Q&A  >  body text

javascript - vue v-for loop, the key value of the parent loop needs to be obtained in the sub-loop, how to do it?

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.

某草草某草草2645 days ago983

reply all(2)I'll reply

  • 某草草

    某草草2017-06-26 10:58:33

    Okay, I found the problem, just replace onclick with v-on:click binding event -=

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-26 10:58:33

    Loop data? And it’s still an object

    reply
    0
  • Cancelreply