vue3 生命周期

与 2.x 版本生命周期相对应的组合式 API

复制代码
beforeCreate -> 使用 setup()
created -> 使用 setup()
beforeMount -> onBeforeMount
mounted -> onMounted
beforeUpdate -> onBeforeUpdate
updated -> onUpdated
beforeDestroy -> onBeforeUnmount
destroyed -> onUnmounted
errorCaptured -> onErrorCaptured

使用

javascript 复制代码
	import {onBeforeMount,onMounted } from 'vue'
	
	//在组件被挂载之前调用
	onBeforeMount(()=>{
	   console.log('组件被挂载之前')
	})
	//在组件被挂载之后调用
	onMounted(() => {
	   console.log('在组件被挂载之后')
	});
	
相关推荐
雪碧聊技术17 小时前
v-for的用法及案例
vue3·uniapp·v-for·购物车案例
Modify_QmQ4 天前
leaflet【十一】地图瓦片路径可视化
gis·vue3·leaflet·leafletmapblock
ldj202015 天前
vue3整合element-plus
vue3
夜空孤狼啸19 天前
前端常用拖拽组件库(vue3、react、vue2)
前端·javascript·react.js·typescript·前端框架·vue3
sunshine_程序媛20 天前
vue3中的watch和watchEffect区别以及demo示例
前端·javascript·vue.js·vue3
meng半颗糖21 天前
vue3 双容器自动扩展布局 根据 内容的多少 动态定义宽度
前端·javascript·css·vue.js·elementui·vue3
3D虚拟工厂21 天前
3D虚拟工厂
3d·vue3·blender·数字孪生·three.js
霸王蟹25 天前
前端项目Excel数据导出同时出现中英文表头错乱情况解决方案。
笔记·学习·typescript·excel·vue3·react·vite
佚名猫1 个月前
vue3+vite+pnpm项目 使用monaco-editor常见问题
前端·vue3·vite·monacoeditor
技术闲聊DD1 个月前
Vue3学习(4)- computed的使用
vue3·computed