1.生命周期的钩子函数
beforeCreate(){ console.log("实例创建之前"); }, created(){ console.log("实例创建之后"); }, beforeMount(){ console.log("模板渲染之前"); }, mounted(){ console.log("模板渲染之后"); }, beforeUpdate(){ console.log("数据更新之前"); }, updated(){ console.log("数据更新之后"); }, beforeDestory(){ console.log("实例销毁之前"); }, destoryed(){ console.log("实例销毁之后"); }
2.路由守卫
全局前置守卫
router.beforeEach((to,from,next)=>{ 执行的逻辑})
全局后置守卫
router.afterEach((to,from,next)=>{ 执行的逻辑})
路由独享
beforEnter((to.from,next)=>{ 执行的逻辑})
组件内
beforeRouteEnter //进入组件的时候生效
beforeRouteLeave //离开组件的时候生效
3.keep-alive的钩子函数
activated(){} //进入到keep-alive管理的组件的时候执行
deactivated(){} //离开被keep-alive管理的组件的时候执行

posted on 2021-12-17 20:19  萝源控  阅读(35)  评论(0)    收藏  举报