美文网首页
Vue组件的生命周期

Vue组件的生命周期

作者: brave_wu | 来源:发表于2023-05-31 10:27 被阅读0次

    vue组件生命周期3步走:
    挂载: beforeCreate => created => beforeMount => mounted
    更新: beforeUpdate => updated
    销毁: beforeDestroy => destroyed

    父子组件:
    挂载: 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
    总结就是:
    挂载时,子组件是在父组件before mount后开始挂载,并且子组件先mounted
    更新时,子组件是在父组件before update后开始更新,子组件先于父组件更新
    销毁时,子组件是在父组件before destroy后开始销毁,并且是子组件先销毁

    相关文章

      网友评论

          本文标题:Vue组件的生命周期

          本文链接:https://www.haomeiwen.com/subject/hrafsdtx.html