Using Vue2 I'm trying to create some input tags which have dynamic content. I have tried binding it to some function :name="someFunction" but that doesn't seem to work on this occasion. I need the name attribute to be in the format
people[0]['name']
people[1]['name']
With the number value being the key value of the loop over people. I usually create ajax/axios requests based on the stored model but on the occasion that method isn't possible.
Here is an example snippet of what I've got currently:
new Vue({
el : '#example',
data : {
people : [
{
name : 'Tom',
age : 12
},
{
name : 'Susan',
age : 18
},
]
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="example">
<div v-for="(person,key) in people">
<input type="text" name="people[key]['name']" :value="person.name">
<!-- The name should be dynamic people[0]['name'] -->
<!-- and people[1]['name'] -->
</div>
</div>
Many thanks in advance