Arrays

  1. In the HTML, to achieve the same result, edit the list to reflect the following:
        <ul>             <li v-for="n in [10,9,8,7,6,5,4,3,2,1]">{{n}}</li>             <li>launch missile!</li>         </ul>

Although this list is identical to the previous one, we shouldn't put literal arrays in HTML markup.

  1. We're better off with a variable that contains the array. Edit the preceding code to match the following:
        <ul>           <li v-for="n in countdown">{{n}}</li>           <li>launch missile!</li>         </ul>
  1. Then put the array countdown in the JavaScript:
        new Vue({           el:'#app',           data: {             countdown: [10,9,8,7,6,5,4,3,2,1]           }         })

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.