v-for:

v-for 指令需要以 site in sites 形式的特殊语法, sites 是源数据数组并且 site 是数组元素迭代的别名。

demo1.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="../js/vue.js"></script>
</head>
<body>
<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:"a",hp:341},
{name:"b",hp:225},
{name:"c",hp:427},
{name:"d",hp:893}
];
new Vue({
el: '#div1',
data: {
heros:data
}
})
</script>
</body>
</html>

2.显示下标

<div id="div1">
<table align="center" >
<tr class="firstLine">
<td>name</td>
<td>hp</td>
<td>index</td>
</tr>
<tr v-for="hero,index in heros">
<td>{{hero.name}}</td>
<td>{{hero.hp}}</td>
<td>{{index}}</td>
</tr>
</table>
</div>

3.遍历数字

<div v-for="i in 10" style="margin-left: 25rem;">
<td>{{i}}</td>
</div>

demo4

<div id="app">
<ul>
<li v-for="o in ob">
{{o}}
</li>
<br />
<li v-for="(key ,value) in ob">
{{key}}:{{value}}
</li>
<br />
<li v-for="(index,key,value) in ob">
{{index}} , {{key}} , {{value}}
</li>
</ul>
</div>
<script>
new Vue({
el:'#app',
data:{
ob:{
name:'happy',
age:'111',
id:'11'
}
}
})
</script>

最新文章

  1. Mysql中eft join、right join、inner join的区别
  2. ModelState.IsValid总为false原因
  3. java关键字 super 和 this
  4. 关于dvajs里effects的call和put
  5. iOS开发直播需要的准备
  6. SQL 行转列和列转行2
  7. HBase预分区
  8. 移动端调试工具DebugGap推荐。
  9. Rest API 开发 学习笔记(转)
  10. 0030 Linux 网络操作命令
  11. delphi中的Label控件背景透明
  12. hdu10007
  13. Nuget找不到服务器
  14. [Codeforces Round #192 (Div. 2)] D. Biridian Forest
  15. hdu 1823 Luck and Love 二维线段树
  16. eclipse+git
  17. aggregate聚合
  18. c#Dapper 批量插入Mysql
  19. Linter pylint is not installed
  20. Java解决小孩围圈问题

热门文章

  1. 【Pycharm使用者必看】自定义【光标快速定位到行尾】的按键
  2. ELK:收集Docker容器日志
  3. 【译文连载】 理解Istio服务网格(第二章 安装)
  4. GDAL利用地理坐标读取图像像元值
  5. 使用Python打造一款间谍程序
  6. Python 元类 - Metaclasses
  7. stm32f407使用Keil uV5建立工程日志
  8. H5谷歌登录 webview错误
  9. python pandas合并多个excel(xls和xlsx)文件(弹窗选择文件夹和保存文件)
  10. 3,HDFS原理