父子组件钩子函数执行顺序
父 beforeCreate
父 created
父 beforeMount
子 beforeCreate
子 created
子 beforeMount
子 mounted
父 mounted
子组件若有 props 的话更新顺序是四步,若无的话两步不触发父亲的钩子
父 beforeUpdate
子 beforeUpdate
子 updated
父 updated
父组件更新顺序
父 beforeUpdate
子 deactivated
父 updated
销毁过程
父 beforeDestroy
子 beforeDestroy
子 destroyed
父 destroyed
实际案例
父组件在mounted中 $emit 发射事件,子组件在mounted中 $on 注册父组件的事件。
本文详细介绍了Vue.js中父子组件的生命周期钩子函数执行顺序,包括创建、挂载、更新及销毁等各个阶段,并通过实际案例说明了如何在特定钩子函数中使用$emit和$on进行父子组件间的通信。
318

被折叠的 条评论
为什么被折叠?



