← Vue.js Foundations
7 / 25
Lesson 7 — Rendering lists
Lists of objects
Most real lists hold objects, not plain strings. With v-for="f in fruits" each f is an object, so you print its fields ({{ f.name }}) and use a stable field such as f.id as the :key — not the text, which might repeat.
<li v-for="u in users" :key="u.id">{{ u.name }} ({{ u.age }})</li>
Why it matters: data from an API almost always arrives as an array of objects with ids.
Want it another way?
Task
Render one <li> per fruit showing "name: $price", keyed by id. The preview should list apple: $2, banana: $1, cherry: $5.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.