SyntaxStudy
Sign Up
Vue.js v-for List Rendering
Vue.js Beginner 1 min read

v-for List Rendering

The `v-for` directive renders a list of items based on an array, object, or integer range. When iterating arrays it exposes `(item, index)` and when iterating objects it exposes `(value, key, index)`. Always provide a `:key` binding with a stable unique identifier — typically the item's ID — so Vue's virtual-DOM diffing algorithm can efficiently reorder, add, or remove DOM nodes without unnecessary re-renders. Avoid using the loop index as the key when items can be reordered or filtered, because index-based keys cause Vue to reuse the wrong DOM node. A key should be unique to the data entity, not its position. Keys must be strings or numbers and should not be objects. `v-for` can be placed on `