没有合适的资源?快使用搜索试试~ 我知道了~
首页浅析vue中常见循环遍历指令的使用 v-for
vue中循环遍历使用的指令是v-for 1.v-for遍历数组 (1)value in arr 遍历数组中的元素 (2)(value,index) in arr 遍历数组中的元素和数组下标 运行代码: <body> <div class=box> <ul> <li v-for=value>{{value}}</li><br> <li v-for=(value,index)>{{value}}--{{index}}</li> </ul> </div> [removed]</s
资源详情
资源评论
资源推荐

浅析浅析vue中常见循环遍历指令的使用中常见循环遍历指令的使用 v-for
vue中循环遍历使用的指令是v-for
1.v-for遍历数组遍历数组
(1)value in arr 遍历数组中的元素
(2)(value,index) in arr 遍历数组中的元素和数组下标
运行代码:
<body>
<div class="box">
<ul>
<li v-for="value in arr">{{value}}</li><br>
<li v-for="(value,index) in arr">{{value}}--{{index}}</li>
</ul>
</div>
<script src="js/vue.js"></script>
<script>
new Vue({
el:".box",
data:{
arr:["哈哈","嘻嘻","哼哼"] }
});
</script>
</body>
输出结果:
2.v-for遍历遍历json对象对象
(1)value in json 遍历json对象中的值
(2)(value,key) in json 遍历json对象中的值和键
(3)(value,key,index) in json 遍历json对象中的值、键和索引
运行代码:
<body>
<div class="box">
<ul>
<li v-for="value in json">{{value}}</li><br>
<li v-for="(value,key) in json">{{value}}--{{key}}</li><br>
<li v-for="(value,key,index) in json">{{value}}--{{key}}--{{index}}</li>
</ul>
</div>
<script src="js/vue.js"></script>
<script>
new Vue({
el:".box",
data:{
json:{
baidu:"百度",
souhu:"搜狐",
sougou:"搜狗"
}
}
});
</script>
</body>



















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0