ly2011 / blog

前端学习笔记
https://ly2011.github.io/blog
122 stars 12 forks source link

Vue 的父组件和子组件生命周期钩子执行顺序是什么? #173

Open ly2011 opened 5 years ago

ly2011 commented 5 years ago

Vue 的父组件和子组件生命周期钩子执行顺序是什么

gaoyafengyagao commented 5 years ago

父beforeCreate->父Created->父beforeMount->子beforeCreate->子created->子beforeMount->子mounted->父mounted->

父beforeUpdate->子beforeUpdate->子update->父update

父beforeDestroy->子beforeDestory->子destroyed->父destroyed

ly2011 commented 5 years ago
  1. 加载渲染过程 父beforeCreate->父created->父beforeMount->子beforeCreate->子created->子beforeMount->子mounted->父mounted
  2. 子组件更新过程 父beforeUpdate->子beforeUpdate->子updated->父updated
  3. 父组件更新过程 父beforeUpdate->父updated
  4. 销毁过程 父beforeDestroy->子beforeDestroy->子destroyed->父destroyed