BeginnerCoder

Lesson 3 — v-for

One element per item

v-for repeats an element for every item in an array: v-for="item in items". Each copy can use item. Bind a unique :key (the colon means "this is JavaScript, not text") so Vue can track which element belongs to which item.

<li v-for="c in colors" :key="c">{{ c }}</li>

Why it matters: menus, product grids and message lists are all v-for loops.

Want it another way?
Task

Add "Ship" and render each item as an <li>. The preview should show a 3-item list: Learn, Build, Ship.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.