javascript / beginner
Snippet
List Rendering with v-for
The v-for directive is used to render a list of items based on an array. It requires a special :key attribute to help Vue efficiently track and update the DOM elements.
snippet.js
javascript
1
2
3
4
5
<ul><li v-for="user in users" :key="user.id">{{ user.name }}</li></ul>
vue
Breakdown
1
v-for="user in users"
Iterates through the 'users' array, assigning each element to the local variable 'user'.
2
:key="user.id"
Provides a unique identifier for each item, which is essential for rendering performance.
3
{{ user.name }}
Uses 'Mustache' syntax to output the name property of the current user.