Skip to content

VUE 的生命周期 #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
suukii opened this issue Jul 13, 2020 · 0 comments
Open

VUE 的生命周期 #22

suukii opened this issue Jul 13, 2020 · 0 comments
Labels

Comments

@suukii
Copy link
Owner

suukii commented Jul 13, 2020

总共分为 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 结构依然存在。
@suukii suukii added the vue label Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant