vue3生命周期函数介绍
vue3语法中有哪些生命周期函数,下面编程教程网小编给大家简单介绍一下各种生命周期函数!
生命周期函数代码如下:
vue2与vue3在生命周期的区别:
vue2 | vue3 |
---|---|
beforeCreate | setup() 开始创建组件之前,创建的是data和method |
created | setup() |
beforeMount | onBeforeMount 组件挂载到节点上之前执行的函数。 |
mounted | onMounted 组件挂载完成后执行的函数 |
beforeUpdate | onBeforeUpdate 组件更新之前执行的函数。 |
updated | onUpdated 组件更新完成之后执行的函数。 |
beforeDestroy | onBeforeUnmount 组件挂载到节点上之前执行的函数。 |
destroyed | onUnmounted 组件卸载之前执行的函数。 |