zoukankan      html  css  js  c++  java
  • Vue 的父组件和子组件生命周期钩子函数执行顺序

    Vue 的父组件和子组件生命周期钩子函数执行顺序可以归类为以下 4 部分:

    • 加载渲染过程

      父 beforeCreate -> 父 created -> 父 beforeMount -> 子 beforeCreate -> 子 created -> 子 beforeMount -> 子 mounted -> 父 mounted

    注意 mounted 不会保证所有的子组件也都一起被挂载。如果你希望等到整个视图都渲染完毕,可以在 mounted 内部使用 vm.$nextTick

    mounted: function () {
      this.$nextTick(function () {
        // Code that will run only after the
        // entire view has been rendered
      })
    }
    • 子组件更新过程

      父 beforeUpdate -> 子 beforeUpdate -> 子 updated -> 父 updated

    • 父组件更新过程

      父 beforeUpdate -> 父 updated

    • 销毁过程

      父 beforeDestroy -> 子 beforeDestroy -> 子 destroyed -> 父 destroyed

     

  • 相关阅读:
    PHP04
    PHP03
    PHP02
    PHP01
    jquery attr()方法获取input的checked属性问题
    vue案例
    js基础(数组)
    js基础
    POJ1659 可图性判定
    ZOJ3329 概率DP
  • 原文地址:https://www.cnblogs.com/mengfangui/p/12546520.html
Copyright © 2011-2022 走看看