-
Notifications
You must be signed in to change notification settings - Fork 0
/
04.html
58 lines (54 loc) · 873 Bytes
/
04.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
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.demo {
width: 100px;
height: 100px;
background-color: gray;
display: inline-block;
margin: 10px;
}
.red {
background: red;
}
.green {
background: green;
}
.blue {
background: blue;
}
</style>
</head>
<body>
<div id="app">
<div class="demo"
@click="attachRed = !attachRed"
:class="divClasses"></div>
<div class="demo" :class="{red: attachRed}"></div>
<div class="demo" :class="color"></div>
<hr>
<input type="text" v-model="color">
</div>
</body>
<script src="vue.js"></script>
<script>
new Vue({
el: '#app',
data: {
attachRed: false,
color: 'green'
},
computed: {
divClasses: function() {
return {
red: this.attachRed,
blue: !this.attachRed
}
}
}
});
</script>
</html>