-
Notifications
You must be signed in to change notification settings - Fork 0
/
computed.html
68 lines (62 loc) · 1.27 KB
/
computed.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
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
<script src="https://unpkg.com/vue@3"></script>
</head>
<body>
<style>
.box {
background-color: #ccc;
display: inline-block;
margin-right: 5px;
width: 150px;
height: 150px;
}
.red {
background-color: red;
}
.blue {
background-color: blue;
}
</style>
<div id="colortest">
<div
@click="addClass = !addClass"
:class="divClass" class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<div id="xxx">
<xxxx></xxxx>
<xxxx></xxxx>
</div><
script>
Vue.component("xxxx", {
data: function () {
return {
title: "deneme",
};
},
template: "<p>Merhaba Dünya {{title}}</p>",
});new Vue({
el: "#xxx",
});
Vue.createApp({
data() {
return { addClass : false }
},
computed : {
divClass : function() {
return {
red : this.addClass,
blue : !this.addClass
}
}
}
}).mount('#colortest')
</script>
</body>
</html>