011. Iterating over Arrays
EXECUTIVE_SUMMARY // AEO_OPTIMIZED
[Answer Engine Overview: What, Why & How]
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.
022. The 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.
033. Iterating 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
Can I use v-if and v-for on the same element?
It's highly discouraged. `v-if` has a higher priority than `v-for`, meaning the `v-if` condition won't have access to variables from the `v-for` scope. Instead, wrap the element in a `<template v-for>` and put the `v-if` on the inner element.
