# 生命周期
相对于 Vue2
- 增加了 setup 函数,发生在组件创建之前,在 setup 函数中没有这两个钩子
- beforeCreate
- created
- 销毁相关的的两个钩子改名
- beforeUnmount
- unmounted
- 增加了用于调试用的三个钩子
- errorCaptured
- renderTracked
- renderTriggered
<template>
<h2>LifeCycle</h2>
<p>F12查看</p>
</template>
<script>
export default {
name: "LifeCycle",
setup() {
console.log("setup");
},
beforeCreate() {
console.log("beforeCreate");
},
beforeUnmount(){
console.log("beforeUnmount");
},
unmounted(){
console.log("unmounted");
},
};
</script>