Arrays with index notation

When enumerating an array, we also have access to the index, represented by the variable i in the following code:

  1. The HTML becomes:
        <div id="app">           <ul>             <li v-for="(animal, i) in animals">              The {{animal}} goes {{sounds[i]}}            </li>           </ul>         </div>
  1. In the code part, write:
        new Vue({           el: '#app',           data: {             animals: ['dog', 'cat', 'bird'],             sounds: ['woof', 'meow', 'tweet']           }         })

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.