Menu
CoddyTech

Rendering Lists

Part of the Fundamentals section of Coddy's Vue journey. Lesson 23 of 55.

Use v-for to render each array item. This template creates two list items, showing Red and Blue.

const colors = ref(['Red', 'Blue']);
// <ul><li v-for="color in colors" :key="color">{{ color }}</li></ul>

The alias color refers to one item inside the repeated element. For objects, read properties such as color.name and use a stable unique id as the key. Rendering follows the source array order when that array changes.

challenge icon

Challenge

Easy

Render the supplied team array as one li per name inside ul#result. Use v-for and a unique name key. Button #reverse must reverse the array so the displayed order follows it.

Try it yourself

<!doctype html><html><head><meta charset="UTF-8"><title>Vue practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals