vue生命周期

vue实例被创建时经过的初始化过程:

开始创建、初始化数据、编译模版、挂载Dom==>渲染、更新==>渲染、卸载

vue生命周期_第1张图片
生命周期

1、单组件生命周期

    初始化组件:beforeCreate/created/beforeMount/mounted

    响应式数据改变:beforeUpdate/updated

    未缓存组件切换:beforeDestroy/destroyed

2、父子组件生命周期

    子组件在父组件完成挂载DOM前初始化。子组件挂载完成后父组件自动执行更新钩子函数。

    完成销毁父组件先销毁子组件。

    初始化:parent-beforeCreate/parent-created/parent-beforeMount

/child-beforeCreate/child-created/child-beforeMount/child-mounted

parent-mounted/parent-beforeUpdate/parent-updated

    props改变:parent-beforeUpdate/child-beforeUpdate/child-updated/parent-updated

    父组件销毁:parent-beforeDestroy/child-beforeDestroy/child-destroyed/parent-destroyed

3、兄弟组件生命周期

    初始化:

    child1-beforeCreate/child1-created/child1-beforeMount

    /child2-beforeCreate/child2-created/child2-beforeMount

    /child1-mounted/child2-mounted

    组件挂载从上到下进行。

4、混入mixin生命周期

    混入mixin的每一个生命周期钩子函数紧紧优先执行。

你可能感兴趣的:(vue生命周期)