vue3生命周期函数介绍

813 ℃

vue3语法中有哪些生命周期函数,下面web建站小编给大家简单介绍一下各种生命周期函数!

生命周期函数代码如下:

//创建前
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在生命周期的区别:

vue2vue3
beforeCreatesetup() 开始创建组件之前,创建的是data和method
createdsetup()
beforeMountonBeforeMount 组件挂载到节点上之前执行的函数。
mountedonMounted 组件挂载完成后执行的函数
beforeUpdateonBeforeUpdate 组件更新之前执行的函数。
updatedonUpdated 组件更新完成之后执行的函数。
beforeDestroyonBeforeUnmount 组件挂载到节点上之前执行的函数。
destroyedonUnmounted 组件卸载之前执行的函数。

Element UI中文官网Element Plus是一套基于Vue3.0的桌面端组件库

vue3项目如何正确引入新版高德地图(完整代码)

vue3如何解决store.state.count错误的取值

vue3相对于vue2有哪些新特性?

vue2和vue3的5大不同点介绍

标签: vue3, 生命周期

上面是“vue3生命周期函数介绍”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_3197.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

生活小工具

收录了万年历、老黄历、八字智能排盘等100+款小工具!生活小工具
js如何获取x的绝对值
织梦cms分页页码如何控制多少
vue项目如何做图片渲染
MySQL出现1171错误如何解决?
帝国CMS如何在内容页模板里调用附属专题