Vue · Junior · Question 22 of 75

How do you render a list?

<li v-for="todo in todos" :key="todo.id">{{ todo.text }}</li>

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.

Further reading

Problem with a question

Vue · Junior · question 22

Test yourself

Take the Vue · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz