1Vue.createApp({
2 data() {
3 return {
4 items: [{ message: 'Foo' }, { message: 'Bar' }]
5 }
6 }
7}).mount('#array-rendering')
8
9
10
11<ul id="array-rendering" class="demo">
12 <li v-for="item in items" :key="item.message">
13 {{ item.message }}
14 </li>
15</ul>
1<!-- To gain access to the array index: -->
2<ul>
3 <li v-for="(game, index) in games"></li>
4</ul>
5<!--
6 You only want the index in specific cases. Use `:key` as
7 standard. See the other greps.
8-->
1<ul>
2 <li v-for="(item, index) in items">
3 {{ index }} - {{ item }}
4 </li>
5</ul>