Vue TutorialLesson 7Free preview
Vue v-for
This lesson is part of Vue · All levels
Summary
The v-for directive is used to render a list of elements based on a collection, which can be an array, object, number, or range. The values available within the v-for block are local to the scope of the repetition. Vue strongly recommends including key attributes with unique values to keep track and update lists efficient.
Key points
- V-for repeats elements based on array, object, number, or range.
- Common syntax: v-for="item in list" or (item, index) in list.
- The object can be repeated with v-for="(value, key, index) in the object".
- Always include a unique key for proper performance and tracking.
- V-if and v-for should not be used on the same element.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.