总共分为 8 个 - 创建前后 (beforeCreate, created) - 在 beforeCreate 阶段,VUE 实例的挂载元素 el 还不存在。 - 挂载前后 (beforeMount, mounted) - 在 beforeMount 阶段,VUE 实例的 `$el` 和 `data` 都已经初始化了,但还是虚拟 DOM 节点,模板中的 `data.message` 还未替换。 - 在 mounted 阶段,VUE 实例挂载完成,模板中的 `data.message` 成功渲染。 - 更新前后 (beforeUpdate, updated): - `data` 发生变化时会触发这两个生命周期函数 - 销毁前后 (beforeDestroy, destroyed): - 在执行 `destroy` 方法之后,对 `data` 的修改不会再触发生命周期函数,此时 VUE 实例已经解除了事件监听和 DOM 绑定,但 DOM 结构依然存在。
总共分为 8 个
创建前后 (beforeCreate, created)
挂载前后 (beforeMount, mounted)
$el和data都已经初始化了,但还是虚拟 DOM 节点,模板中的data.message还未替换。data.message成功渲染。更新前后 (beforeUpdate, updated):
data发生变化时会触发这两个生命周期函数销毁前后 (beforeDestroy, destroyed):
destroy方法之后,对data的修改不会再触发生命周期函数,此时 VUE 实例已经解除了事件监听和 DOM 绑定,但 DOM 结构依然存在。