-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlife_cycle.html
53 lines (47 loc) · 1012 Bytes
/
life_cycle.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
<!DOCTYPE html>
<html lang="ch">
<head>
<meta charset="utf-8">
<title>Vue-生命周期</title>
<script src="./vue.js" ></script>
</head>
<body>
<div id="app">{{content}}</div>
<script>
// vue 生命周期函数就是 vue 实例在某一个时间点会执行的函数
var app = new Vue({
el: '#app',
data: {
content: 'hellow word'
},
// 注意:这些函数不是放在 methods 里的
beforeCreate: function () {
console.log("beforeCreate")
},
created: function () {
console.log("created")
},
beforeMount: function () {
console.log("beforeMount")
console.log(this.$el)
},
mounted: function () {
console.log("mounted")
console.log(this.$el)
},
beforeDestroy: function() {
console.log("beforeDestroy")
},
destroyed: function() {
console.log("destroyed")
},
beforeUpdate: function() {
console.log("beforeUpdate")
},
updated: function() {
console.log("updated")
}
})
</script>
</body>
</html>