Open Kelichao opened 4 years ago
vue 父子组件的生命周期顺序
moofyu 0.086 2020.03.15 18:21:59 字数 302 阅读 1,006
同步引入时生命周期顺序为: 父组件的beforeCreate、created、beforeMount --> 所有子组件的beforeCreate、created、beforeMount --> 所有子组件的mounted --> 父组件的mounted 总结:父组件先创建,然后子组件创建;子组件先挂载,然后父组件挂载 若有孙组件呢? 父组件先beforeCreate => created => beforeMount , 然后子组件开始beforeCreate => created => beforeMount ,然后孙组件beforeCreate => created => beforeMount => mounted,孙组件挂载完成了,子组件mounted,父组件再mounted 异步引入时生命周期顺序为: 父组件的beforeCreate、created、beforeMount、mounted --> 子组件的beforeCreate、created、beforeMount、mounted
总结:父组件创建,父组件挂载;子组件创建,子组件挂载。
3.父组件更新过程 父beforeUpdate->父updated
4.销毁过程 父beforeDestroy->子beforeDestroy->子destroyed->父destroyed
参考文章
vue 父子组件的生命周期顺序
moofyu 0.086 2020.03.15 18:21:59 字数 302 阅读 1,006
同步引入时生命周期顺序为: 父组件的beforeCreate、created、beforeMount --> 所有子组件的beforeCreate、created、beforeMount --> 所有子组件的mounted --> 父组件的mounted 总结:父组件先创建,然后子组件创建;子组件先挂载,然后父组件挂载 若有孙组件呢? 父组件先beforeCreate => created => beforeMount , 然后子组件开始beforeCreate => created => beforeMount ,然后孙组件beforeCreate => created => beforeMount => mounted,孙组件挂载完成了,子组件mounted,父组件再mounted 异步引入时生命周期顺序为: 父组件的beforeCreate、created、beforeMount、mounted --> 子组件的beforeCreate、created、beforeMount、mounted
总结:父组件创建,父组件挂载;子组件创建,子组件挂载。
3.父组件更新过程 父beforeUpdate->父updated
4.销毁过程 父beforeDestroy->子beforeDestroy->子destroyed->父destroyed
参考文章