Vue列表渲染


浏览:234 次

如果需要呈现一组数据,可以使用v-for指令。v-for指令需要items块中的item来声明这些数据的迭代。这里,in也可以更改为的。如果需要获得迭代的索引,可以将迭代块声明为(item,index)in items。除了迭代列表之外,还可以迭代对象的属性。

列表渲染</h1>

<;h3>姓名列表</h3>

<;ul>

 书信电报;li v-for=“name in names”>;{{name}}

<;/ul>

<;h3>人员表</h3>

<;表>

 书信电报;茶>

 书信电报;tr>

 nbsp;&书信电报;td>编号</td>

 nbsp;&书信电报;td>名称</td>

 nbsp;&书信电报;td>年龄</td>

 lt;/tr>

 lt;/茶>

 书信电报;t车身>

 书信电报;tr v-for=“(person,index)of people”:key=“index”>;

 nbsp;&书信电报;td>{{索引}}

 nbsp;&书信电报;td>{{person.name}}

 nbsp;&书信电报;td>{{person.age}}

 lt;/tr>

 lt;/t车身>

<;/表>

<脚本>

让vm5=新Vue({

;el:'#s5',

;数据:{

 nbsp;姓名:[

 nbsp; ;##39; zhang3’,

 nbsp; ;##39; li4′,

 nbsp; ;##39; 益田',

 nbsp; ;##39; 乔乔

 nbsp;],

 nbsp;人员:[

 nbsp; ;{姓名:'zhang3',年龄:24},

 nbsp; ;{name:“li4”,年龄:25},

 nbsp; ;{姓名:'益田',年龄:24},

 nbsp; ;{姓名:“jojo”,年龄:30岁}

 nbsp;]

}

})

相关资讯:
农产品电子商务向企业个人农产品电子贸易方向发展的效益

农产品电子商务向企业个人农产品电子贸易方向发展的效益

查看
Web 3.0技术的基本方向

Web 3.0技术的基本方向

查看
认知

认知

查看
面向对象的

面向对象的

查看
2018-12-25

2018-12-25

查看