-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-for.html
42 lines (39 loc) · 867 Bytes
/
v-for.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue-循环</title>
<script src="js/vue.js"></script>
<script>
//v-for 循环获取数据
window.onload = function () {
new Vue({
el: "#box",
data: {
list: ['a', 'b', 'c'],
json: {a: "hh", b: "kk", c: "ll"}
}
})
}
</script>
</head>
<body>
<div id="box">
<ul>
<li v-for="value in list">{{value}} {{$index}}</li><!--index是指的是当前item的下标 -->
</ul>
<hr>
<ul>
<li v-for="value in json">
{{value}} {{$index}} {{$key}}
</li>
</ul>
<hr>
<ul>
<li v-for="(k,v) in json">
{{k}} {{v}} {{$index}} {{$key}}
</li>
</ul>
</div>
</body>
</html>