Skip to content

VUE 的生命周期 #22

@suukii

Description

@suukii

总共分为 8 个

  • 创建前后 (beforeCreate, created)

    • 在 beforeCreate 阶段,VUE 实例的挂载元素 el 还不存在。
  • 挂载前后 (beforeMount, mounted)

    • 在 beforeMount 阶段,VUE 实例的 $eldata 都已经初始化了,但还是虚拟 DOM 节点,模板中的 data.message 还未替换。
    • 在 mounted 阶段,VUE 实例挂载完成,模板中的 data.message 成功渲染。
  • 更新前后 (beforeUpdate, updated):

    • data 发生变化时会触发这两个生命周期函数
  • 销毁前后 (beforeDestroy, destroyed):

    • 在执行 destroy 方法之后,对 data 的修改不会再触发生命周期函数,此时 VUE 实例已经解除了事件监听和 DOM 绑定,但 DOM 结构依然存在。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions