I want to build a dynamic form with list groups and user can add, remove and reorder them, with transition. But i dont know how to set key for each item inside v-for loop. As document say use object as key is bad idea, or use index as same as not use key at all. Could anyone show me a good solution for this.
<div id="root">
<transition-group name="flip-list" tag="div">
<div class="form-group" v-for="(item, index) in items" :key="what key to use">
<input type="text" name="name" v-model="item.name">
<input type="tel" name="tel" v-model="item.tel">
</div>
</transition-group>
<button @click="add_item">Add</button>
</div>
<script>
new Vue({
el: '#root',
data: {
items: []
},
methods: {
add_item: function () {
this.items.push({
name: '',
tel: ''
})
}
}
})
</script>