
vue3生命周期
发布日期:2021-05-09 02:48:34
浏览次数:20
分类:精选文章
本文共 522 字,大约阅读时间需要 1 分钟。
介绍
vue3的生命周期函数,可以按需导入到组件中,且只能在 setup()
函数中使用
示例
import { onMounted, onUpdated } from '@vue/composition-api'export default { setup() { onMounted(() => { console.log('mounted') }) onUpdated(() => { console.log('updated') }) }}
对比vue2.x
-> 使用beforeCreate
setup()
-> 使用created
setup()
beforeMount
->onBeforeMount
mounted
->onMounted
beforeUpdate
->onBeforeUpdate
updated
->onUpdated
beforeDestroy
->onBeforeUnmount
destroyed
->onUnmounted
errorCaptured
->onErrorCaptured
发表评论
最新留言
不错!
[***.144.177.141]2025年05月08日 17时17分27秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!