看程序学Vue.js 4- VUE.JS 使用 V-FOR 循环语句实例
2019-06-28 20:24
871 查看
步骤 1 : v-for 循环语句
<script src="http://how2j.cn/study/vue.min.js"></script> <style> table tr td{ border:1px solid gray; } table{ border-collapse:collapse; width:300px; } tr.firstLine{ background-color: lightGray; } </style> <div id="div1"> <table align="center" > <tr class="firstLine"> <td>name</td> <td>hp</td> </tr> <tr v-for="hero in heros"> <td>{{hero.name}}</td> <td>{{hero.hp}}</td> </tr> </table> </div> <script> var data = [ {name:"盖伦",hp:341}, {name:"提莫",hp:225}, {name:"安妮",hp:427}, {name:"死歌",hp:893} ]; new Vue({ el: '#div1', data: { heros:data } }) </script> 试一下
步骤 2 : index用法
<script src="http://how2j.cn/study/vue.min.js"></script> <style> table tr td{ border:1px solid gray; } table{ border-collapse:collapse; width:300px; } tr.firstLine{ background-color: lightGray; } </style> <div id="div1"> <table align="center" > <tr class="firstLine"> <td>number</td> <td>name</td> <td>hp</td> </tr> <tr v-for="hero,index in heros"> <td>{{index+1}}</td> <td>{{hero.name}}</td> <td>{{hero.hp}}</td> </tr> </table> </div> <script> var data = [ {name:"盖伦",hp:341}, {name:"提莫",hp:225}, {name:"安妮",hp:427}, {name:"死歌",hp:893} ]; new Vue({ el: '#div1', data: { heros:data } }) </script>
步骤 3 : 纯数字遍历
<script src="http://how2j.cn/study/vue.min.js"></script> <div id="div1"> <div v-for="i in 10"> {{ i }} </div> </div> <script> new Vue({ el: '#div1' }) </script>
相关文章推荐
- js---javaScript(循环语句的使用实例)for while do....while(转移语句): break, continue , return
- 学习使用vue.js(三)条件与循环 v-if、 v-for
- vue.js中请求数据v-for循环使用数据
- js 中的for 循环语句的使用(练习)
- for循环语句嵌套使用的实例
- 简单编程(六)使用for循环语句 编写程序1+2+3+...........+100
- Vue.js常用指令之循环使用v-for指令教程
- php for 循环语句使用方法详细说明
- 牛腩购物 8 整合用户留言 动软生成器 ,.NET在后置代码中输入JS提示语句(背景不会变白),repeater 循环的时候事件判断,repeater 隔行 奇数行,item列,隐藏区块 Panel 的使用,前台绑定代码的时候使用函数
- 使用for循环语句输出九九乘法表
- linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例
- linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例 --转载
- Objective-C学习笔记(十)——循环语句for和do-while的使用
- linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例
- linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例
- linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例
- Shell 脚本之循环语句(for,while,until)以及case,select,break,continue实例详解
- 快速学习C语言中for循环语句的基本使用方法
- Python的for和break循环结构中使用else语句的技巧
- 微信小程序使用第三方库Immutable.js实例详解