最近感到对vue-router中路由跳转的钩子函数比较混乱。
稍微总结一下了相关的基本结构
Vue中的声明周期
结构
- 创建
- beforeCreate(){}
- created(){}
- 挂载
- beforeMount()
- mounted(){} 真正挂载
- 更新
- 数据触发重新渲染时,实时聊天
- beforeUpdate(){} 更新前可以对组件进行控制
- updated(){}
- 卸载
- beforeUnmounted
- unmounted
具体执行
-
除了没有创建的声明周期函数,其它的都有
-
挂载
- onBeforeMuont
- onMounted
-
更新
- onBeforeUpdate
- onUpdated
-
卸载
- onBeforeUnmounted
- onUnmounted
创建过程,从外到内。挂载过程从内到外
vue-router中的路由跳转
结构
-
组件守卫
beforeRouteEnter beforeRou