-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
94 lines (88 loc) · 2.21 KB
/
index.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>one-ui</title>
<style>
h3{ color: red; }
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.0.2/webcomponents-bundle.js"></script>
<script src="src/index.js"></script>
</head>
<body>
<script>
class MyDom {
get tagName() {
return 'my-abc';
};
get props() {
return {
abc: JSON
}
}
set abc(newVal) {
console.log(this.data.abc);
this.data.abc = newVal;
console.log(this.data.abc);
}
data() {
return {
name: '谢小呆',
age: 18,
abc: {
},
children: {
name: 'hello',
age: 1
}
};
}
get template() {
return `
<div>
<h3 :class="{}">hi {{ name }} age: {{ age + 1 }} , {{ abc.b.c }}</h3>
<ul>
<li>age: {{ age + 1}}</li>
<li><button @click='sub'>-</button><button @click='add'>+</button></li>
<li>children.name: {{ children.name }}</li>
<li>children.age: {{ children.age < 2 ? 'A': 'B' }}</li>
<li><button @click='subChildrenAge'>-</button><button @click='addChildrenAge'>+</button></li>
<li><button @click='changeName'> change name !</button></li>
<li><button @click='changeName2'> change name !</button></li>
</ul>
</div>
`;
};
get style() {
return `h3{ color: green; }`;
}
get methods() {
return {
add: function() {
this.data.age++;
},
sub: function() {
this.data.age--;
},
changeName: function() {
this.data.name = 'hello!'
},
changeName2: function() {
this.data.children.name = 'helloABC!'
},
addChildrenAge: function() {
this.data.children.age++;
},
subChildrenAge: function() {
this.data.children.age--;
},
}
}
}
window.OneUi.defineComponent(MyDom);
</script>
<my-abc abc='{"b":{"c":2}}'></my-abc>
</body>
</html>