ChenPt / dailyNote

dailyNode for myself
https://github.com/ChenPt/dailyNote/issues
0 stars 0 forks source link

2018/08/31 关于父组件和子组件的生命周期 #31

Open ChenPt opened 5 years ago

ChenPt commented 5 years ago

子组件总是会先于父组件挂载。 一个拥有子组件的组件的生命周期如下 父组件beforeCreate => 父组件Created =>父组件beforeMount=> 子组件beforeCreate => 子组件Created => 子组件beforeMount => 子组件Mounted => 父组件Mounted

需要注意,父组件的mounted不会承诺所有的子组件也都一起被挂载。所以如果需要视图完全渲染完毕,可以用vm.$nextTick来代替mounted