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


猜你喜欢
- ASP.NET Core中快速构建PDF文档的步骤分享 2024-02-25
- css3利用视差实现做一个酷炫交互动效 2024-12-13
- 解决Vue路由导航报错:NavigationDuplicated: Avoided redundant navigation to current location 2024-01-16
- Vue-router中hash模式与history模式的区别详解 2024-02-12
- 一个简单Ajax类库及使用方法实例分析 2022-12-15
- Ajax提交表单页面刷新很快的解决方法 2023-01-26
- 详解CSS透明opacity和IE各版本透明度滤镜filter的最准确用法 2024-02-05
- ASP.NET MVC 3实现访问统计系统 2023-12-23
- 深入浅析CSS 的多种背景及使用场景和技巧 2024-01-03
- JavaScript CollectGarbage函数案例详解 2024-01-14