1 <html lang="en"> 2 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 7 <title>v-for</title> 8 <script src="../js/vue.js"></script> 9 </head> 10 11 <body> 12 <div id="app"> 13 14 <div v-for="(item,i) in list">索引值{{i}}-->拿取他的id值{{item.id}}-->拿取他的昵称--{{item.name}}</div> 15 </div> 16 <script> 17 var vm = new Vue({ 18 el: '#app', 19 data: { 20 list: [{ 21 id: 0, 22 name: "小猫" 23 },{ 24 id: 1, 25 name: "小狗" 26 },{ 27 id: 2, 28 name: "小鱼" 29 } 30 ] 31 } 32 33 }) 34 </script> 35 36 </body> 37 38 </html>