vue - for遍历数组

注释上,也很清楚了哈.

1. item是循环名字,items是循环的数组

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 
 4 <head>
 5     <meta charset="UTF-8">
 6     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 7     <meta http-equiv="X-UA-Compatible" content="ie=edge">
 8     <title>Document</title>
 9     <!-- Step1.对于vue,可以用cdn -->
10     <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
11     <style>
12         #app div{
13             padding: 2%;
14             margin-bottom: 1%;
15             border-bottom: 1px solid #ddd;
16             background-color: blanchedalmond;
17         }
18     </style>
19 </head>
20 
21 <body>
22 
23 
24     <div id="app">
25         <!-- item是循环名字,items是循环的数组 -->
26         <div v-for="item in items">
27             {{item}}
28         </div>
29     </div>
30 
31 
32     <script type="text/javascript">
33         var app = new Vue({
34             el: '#app',
35             data: {
36                 message: 'hello World!',
37                 items:[10,2,3,4,5]
38             }
39         })
40     </script>
41 </body>
42 
43 </html>

猜你喜欢

转载自www.cnblogs.com/cisum/p/9614626.html