forked from shenghy/VueDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-bind.html
56 lines (54 loc) · 1.62 KB
/
v-bind.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="../assets/js/vue.js"></script>
<title>v-bind 案例</title>
</head>
<body>
<h1>v-bind 案例</h1>
<hr>
<div id="app">
<img v-bind:src="imgSrc" width="200px"><br/>
<a :href="jspang" target="_blank">技术胖</a>
<hr>
<div :class="className">1、绑定classA</div>
<div :class="{classA:isOk}">2、绑定class中的判断</div>
<div :class="[classA,classB]">3、绑定class中的数组</div>
<div :class="isOk?classA:classB">4、绑定class中的三元表达式判断</div>
<hr>
<input type="checkbox" id="isTrue" v-model="isOk">
<label for='isTrue'>isOk={{isOk}}</label>
<hr>
<div :style="{color:red,fontSize:font}">5、绑定style</div>
<div :style="styleObject">6、用对象绑定style样式</div>
</div>
<style>
.classA{
color:red;
}
.classB{
font-size:150%
}
</style>
<script type="text/javascript">
var app=new Vue({
el:'#app',
data:{
imgSrc:'http://jspang.com/wp-content/uploads/2017/02/vue01-2.jpg',
jspang:'http://jspang.com',
className:'classA',
isOk:false,
classA:'classA',
classB:'classB',
red:'red',
font:'30px',
styleObject:{
fontSize:'24px',
color:'green'
}
}
})
</script>
</body>
</html>