vue父子组建的生命周期
时间: 2023-08-27 21:15:03 浏览: 127
Vue的父子组件的生命周期是按照以下顺序进行的:
1. 父组件的生命周期: beforeCreate -> created -> beforeMount -> mounted
[1 [2]
2. 子组件的生命周期: beforeCreate -> created -> beforeMount -> mounted
[1 [2]
父组件的生命周期在子组件的生命周期之后,这是因为父组件需要等待子组件挂载完毕后才能完成挂载。在加载渲染过程中,创建实例是从外到内的,渲染是从内到外的。
综合起来,父子组件的生命周期顺序如下:
父beforeCreate -> 父created -> 父beforeMount -> 子beforeCreate -> 子created -> 子beforeMount -> 子mounted -> 父mounted
这个顺序确保了父组件在子组件挂载完毕后再进行挂载,以保证整个组件的正常渲染和操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Vue父子组件的生命周期](https://blog.csdn.net/weixin_45817987/article/details/123482150)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [vue父子组件生命周期](https://blog.csdn.net/qq_25503949/article/details/107351228)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Vue——父子组件的生命周期(执行顺序)](https://blog.csdn.net/leilei__66/article/details/118699960)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文