父组件和子组件生命周期的顺序

  1. 当点击"change it "的时候,引起视图变化,触发beforeUpdate和Update

  2. 当点击"destroy parent1",引发父亲组件的beforeDestroy和destoryed

  3. 当点击“destory children1”,引发子组件的beforeDestroy和destoryed

结论:
parent beforeCreated
parent created
parent beforeMount
child beforeCreated
child created
child beforeMount
parent mounted
当引起视图变化后
parent beforeUpdate
child beforeUpdate
child Update
parent Update
当destroy parent组件,即点击"destory parent1"的时候
parent beforeDestroy
child beforeDestroy
child destroyed
parent destroyed
当destroy children组件,即点击"destory children1"的时候
parent beforeUpdate
child beforeDestroy
child destroyed
parent Update

去下方gitee地址下载,然后打开"生命周期顺序"中的html文件
https://gitee.com/yao_zhongqiang/study_git/tree/dev3

原文地址:https://www.cnblogs.com/listenMao/p/13341764.html