- {{p.name}}-{{p.age}}--{{index}}
汽車資訊
- {{a}}-{{b}}
const vm = new Vue({
data(){
return{
persons:[
{id:'001',name:'張三',age:18},
{id:'002',name:'李四',age:19},
],
car:{
name:'奧迪',
price:'70w',
color:'黑'
}
}},
})
v-for 類似for迴圈,將被迴圈物件中的類全部過一遍,(p,index)分別對應persons中的類和各自獨一無二的index(跟在後面的key=‘index’)