Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Vue 3 v-for Directive

Vue 3 v-for Directive

Vue3 Built-in Directives Vue 3 Built-in Directives


v-for The directive is used to render elements multiple times based on source data; it is the core directive for list rendering in Vue.


Basic Explanation

v-for The directive repeats rendering elements based on an array or object. It lets you repeat a group of similar elements and use values from the data source.


Basic Syntax

Example

  • {{ item }}

  • {{ index }} - {{ item }}

  • {{ key }}: {{ value }}

  • {{ n }}


  • Use Cases

    1. Array Iteration

    Example

    2. Object Array Iteration

    Example


    The Importance of key

    It is strongly recommended to provide a unique key attribute for each loop item in v-for, which helps Vue update the list efficiently.

    Example

  • {{ item.name }}


  • Vue3 Built-in Directives Vue 3 Built-in Directives