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('在组件被挂载之后')
	});
	
相关推荐
麦麦大数据21 小时前
M004_基于Langchain+RAG的银行智能客服系统设计与开发
typescript·langchain·flask·vue3·faiss·rag
哆啦A梦15883 天前
Vue3魔法手册 作者 张天禹 012_路由_(一)
前端·typescript·vue3
麦麦大数据5 天前
M003_中药可视化系统开发实践:知识图谱与AI智能问答的完美结合
人工智能·flask·llm·vue3·知识图谱·neo4j·ner
哆啦A梦15885 天前
Vue3魔法手册 作者 张天禹 015_插槽
前端·vue.js·typescript·vue3
沛沛老爹10 天前
Vue3+TS实战:基于策略模式的前端动态脱敏UI组件设计与实现
前端·ui·vue3·数据安全·策略模式·动态渲染·前端脱敏
gsls20080811 天前
vue3学习笔记
笔记·vue3
平头也疯狂13 天前
RuoYi Office 全景介绍:一个平台管好整个企业
微服务·vue3·springboot·crm·oa·企业管理系统
weixin79893765432...14 天前
vue3 系统的梳理
vue.js·vue3
竟未曾年少轻狂15 天前
Vue3 生命周期钩子
前端·javascript·vue.js·前端框架·生命周期
是梦终空16 天前
计算机毕业设计264—基于Springboot+Vue3+协同过滤的房屋租赁管理系统(源代码+数据库+万字论文+设计文档)
spring boot·毕业设计·vue3·课程设计·毕业论文·协同过滤·房屋租赁管理系统