Vue · Junior · Question 22 of 75
How do you render a list?
<li v-for="todo in todos" :key="todo.id">{{ todo.text }}</li>- ✓Correct answer: With
v-forand a unique:keyper item - 2With
todos.map()directly in the template - 3With
<for each="todo" in="todos">
Explanation
The key helps Vue match items between renders so it can reuse and reorder DOM nodes and keep component state attached to the correct item. Use a stable id, not the index, for dynamic lists.