-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.html
99 lines (98 loc) · 3.11 KB
/
instance.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
95
96
97
98
99
<!DOCTYPE html>
<html lang="zh-TW">
<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>Instance</title>
<style media="screen">
.lifecycle {
width: 100%;
font-size: 0;
vertical-align: top;
}
.lifecycle > ul {
position: sticky;
top: 0;
float: left;
width: 30%;
box-sizing: border-box;
font-size: 12pt;
}
img {
width: 50%;
}
</style>
</head>
<body>
<div id="example">This is Example</div>
<p>物件生命週期,可以使用特定函數在特定機執行。</p>
<div class="lifecycle">
<ul>
<li>
建構
<ul>
<li>beforeCreate</li>
<li>created</li>
</ul>
</li>
<li>
鑲嵌View - ViewModule
<ul>
<li>beforeMounte</li>
<li>mounted</li>
</ul>
</li>
<li>
修改資料
<ul>
<li>beforeUpdate</li>
<li>updated</li>
</ul>
</li>
<li>
解構
<ul>
<li>beforeDestroye</li>
<li>destroyed</li>
</ul>
</li>
</ul>
<img src="https://vuejs.org/images/lifecycle.png" alt="">
</div>
<script src="https://unpkg.com/vue"></script>
<script type="text/javascript">
var data = {
a: 1
}
var vm = new Vue({
el: '#example',
data: data,
beforeCreate: function () {
setTimeout(() => console.log('beforeCreate'))
},
created: function () {
setTimeout(() => console.log('created'))
},
beforeMounte: function () {
setTimeout(() => console.log('beforeMounte'))
},
mounted: function () {
setTimeout(() => console.log('mounted'))
},
beforeUpdate: function () {
setTimeout(() => console.log('beforeUpdate'))
},
updated: function () {
setTimeout(() => console.log('updated'))
},
beforeDestroye: function () {
setTimeout(() => console.log('beforeDestroye'))
},
destroyed: function () {
setTimeout(() => console.log('destroyed'))
},
})
</script>
</body>
</html>