HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///
Total XP: 0|💻 vuejs XP: 0

List Rendering (v-for) in Vue.js

Learn about List Rendering (v-for) in this comprehensive Vue.js tutorial. Master the v-for directive and understand why the :key attribute is absolutely critical for performance.

LOADING ENGINE...

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Render arrays and objects dynamically in the DOM.

1Iterating over Arrays

We can use the v-for directive to render a list of items based on an array. The directive requires a special syntax in the form of item in items, where items is the source data array.

2The Importance of Keys

When Vue is updating a list of elements rendered with v-for, by default it uses an 'in-place patch' strategy. If the order of the data items has changed, Vue will patch each element in-place. To give Vue a hint so it can track each node's identity, you must provide a unique :key attribute.

3Iterating over Objects

You can also use v-for to iterate through the properties of an object. The syntax is (value, key, index) in myObject.

?Frequently Asked Questions

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Continue Learning