最近在编写自己的组件库,所以需要对vue的生命周期非常的了解,顺便复习了一下知识点。
下面场景我们使用两个组件parent和child,parent包含child
众所周知,一个标准组件的执行顺序
graph TD
beforeCreate --> created --> beforeMount --> mounted --> beforeUpdate-->updated-->beforeDestroy-->destroyed
实例中parent,child两个父子组件的执行顺序如下?
parent --- beforeCreate
parent --- created
parent --- beforeMount
child --- beforeCreate
child --- created
child --- beforeMount
child --- mounted
parent --- mounted
parent --- beforeUpdate
child --- beforeUpdate
child --- updated
parent --- updated
parent --- beforeDestroy
child --- beforeDestroy
child --- destroyed
parent --- destroyed
1.0.0
1.parent何时能调用child 2.child何时能调用parent 3.如果我们在父子组件中所有钩子上都写上 this.$nextTick(() => { console.log() });他的执行顺序会是怎样
4.数据从parent注入child,变化时候钩子的调用情况