演示四种v-for循环
- 循环普通数组
- 循环对象数组
- 循环对象中的属性
- 循环数字(从1开始)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="id001" @click.self="inner" class="inner">
<p v-for="(item,i) in list">索引值:{{i}}----value值:{{item}}</p>
<p v-for="item in list1">{{item.id}}----{{item.name}}</p>
<p v-for="(value,key,i) in list2">索引:{{i}}---key:{{key}}---value:{{value}}</p>
<!-- 注意:从1开始-->
<p v-for="count in 10"> 这是第{{count}}次</p>
</div>
<script type="text/javascript" src="../lib/vue.js"></script>
<script type="text/javascript">
var vm =new Vue({
el:'#id001',
data:{
list:['nihao ','string',3,4,5],
list1:[
{id:1,name:'zhangsan'},
{id:2,name:'aaa'},
{id:3,name:'bbbb'},
{id:4,name:'lisi'}
],
list2:{
id:1,
name:'tony'
}
},
methods: {
}
})
</script>
</body>
</html>