Answers for "vue array item splice transition removes last item"

1

vue array item splice transition removes last item

// This happens when you set them item key to index

// Wrong: 
<div v-for="(item, index) in array" :key="index"></div>

// Correct
array = [{
	item: 'example',
	id: 'unique-id'
}]
...
<div v-for="(item, index) in array" :key="item.id"></div>

// The item key is incorrect.
// Generate a unique id for each item
Posted by: Guest on May-19-2021

Browse Popular Code Answers by Language