04生命周期
# 生命周期
beforeCreate 创造之前
created 创造完毕
beforeMount 安装之前(渲染之前)
mounted 渲染完毕
beforeUpdate 更新前
updated 更新后
beforeDestroy销毁之前
destroyed 销毁之后
activated 激活被缓存的组件
deactivated 取消激活
errorCaptured 错误捕捉
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[!cogs]
%accordion%必记🚀%accordion%
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
new Vue({
beforeCreate() {
console.log("创造之前");
},
created() {
console.log("创造之后");
},
beforeMount() {
console.log("安装之前/渲染之前");
},
mounted() {
console.log("渲染完毕");
},
beforeUpdate() {
console.log("更新前");
},
updated() {
console.log("更新后");
},
beforeDestroy() {
console.log("销毁之前/死掉之前");
},
destroyed() {
console.log("销毁之后/死掉之后");
},
activated() {
console.log("激活被缓存的组件");
},
deactivated() {
console.log("取消激活");
},
errorCaptured() {
console.log("错误捕捉");
}
})
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
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
%/accordion%
创造和渲染有什么区别?
创造是vue实例化的过程,渲染是实例化完之后把数据渲染在页面上的过程。
1

编辑 (opens new window)
上次更新: 2023/08/06, 00:38:41