When enumerating an array, we also have access to the index, represented by the variable i in the following code:
- The HTML becomes:
<div id="app"> <ul> <li v-for="(animal, i) in animals"> The {{animal}} goes {{sounds[i]}} </li> </ul> </div>
- In the code part, write:
new Vue({ el: '#app', data: { animals: ['dog', 'cat', 'bird'], sounds: ['woof', 'meow', 'tweet'] } })