什么是Vue的生命周期 ?

使用最多的:
- created:进行axios
- mounted:挂载元素内dom节点的获取;
新老版本生命周期对比

区别:
Componsition API中,生命周期是从vue中导出的,需要用到的要进行导入,setup除外
除setup外,其他的生命周期都是写在setup中
setup函数是发生在beforeCreate之前的
写法:
import {onBeforeMount, onBeforeUnmount, onBeforeUpdate, onMounted, onUnmounted, onUpdated
} from "vue";
export default {setup() {onBeforeMount(() => {//执行函数});onMounted(() => {//执行函数});onBeforeUpdate(() => {//执行函数});onUpdated(() => {//执行函数});onBeforeUnmount(() => {//执行函数});onUnmounted(() => {//执行函数});}
};