Vue · Junior · Question 61 of 75
Why does v-for need a unique :key?
- ✓Correct answer: So Vue can track each item's identity and reuse or move the right DOM nodes and component state
- 2Keys make the list sorted
- 3Without a key the list doesn't render
Explanation
Use a stable id from the data. Without keys, Vue patches in place, which can mix up inputs or component state when the order changes.