The instruction in Vue for looping through data arrays or objects is v-for, and the syntax is . The parameters include: the traversed item item, the optional index index, and the data items to be traversed.
Instructions for looping in Vue
Use the v-for
instruction in Vue Loop through a data array or object.
Syntax:
<code class="html"><template v-for="(item, index) in items"></template></code>
Parameters:
item
: Current loop itemindex
: The index of the current loop item (optional) items
: The data array or object to be traversedUsage:
<code class="html"><ul> <li v-for="item in items">{{ item }}</li> </ul></code>
<code class="html"><ul> <li v-for="(value, key) in object">{{ key }}: {{ value }}</li> </ul></code>
<code class="html"><ul> <li v-for="(item, index) in items">{{ index + 1 }}. {{ item }}</li> </ul></code>
The above is the detailed content of The instruction used for looping in vue is. For more information, please follow other related articles on the PHP Chinese website!