Problem Statement
What is the purpose of the key attribute with v-for?
Explanation
key gives Vue a stable identity for each node so it can efficiently reuse and reorder DOM elements. Use a unique, stable key like an id; avoid array indexes when items can be reordered/removed to prevent incorrect state reuse.
Code Solution
SolutionRead Only
<li v-for="todo in todos" :key="todo.id">{{ todo.text }}</li>