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
|
// <-----html----->
#app
p(v-for="item in a") {{item.name}} //蘋果 //香蕉 //鳳梨
//** 範例一 **//
template(v-for="item in a") {{item.name}} //蘋果香蕉鳳梨
//** 範例二 **//
p(v-for="item in 5") {{item}} //1 //2 //3 //4 //5
//** 範例三 **//
p(v-for="(item,key) in a") {{key}} //0 //1 //2
p(v-for="(item,key) in b") {{key}} //apple //banana //pineapple
//** 範例四 **//
p(v-for="item in a" v-if="item.amount > 200") {{item.name}} //蘋果 //香蕉
// <-----js----->
let app = new Vue({
el: "#app",
data:{
a:[
{name: "蘋果" ,amount: 100},
{name: "香蕉" ,amount: 300},
{name: "鳳梨" ,amount: 500}
],
b:{
apple:{
name: "蘋果",
amount: 100
},
banana:{
name: "香蕉",
amount: 300
},
pineapple:{
name: "鳳梨",
amount: 500
}
}
}
});
|