作者:serafina捡到一枚人鱼 | 来源:互联网 | 2023-08-26 17:19
beforeRouteEnter钩子beforeRouteEnter(to,from,next){console.log(this);undefined,不能用this来获取vue
beforeRouteEnter钩子
beforeRouteEnter (to, from, next) {
console.log(this); //undefined,不能用this来获取vue实例
console.log('组件路由钩子:beforeRouteEnter');
next(vm => {
console.log(vm); //vm为vue的实例
console.log('组件路由钩子beforeRouteEnter的next');
});
}
这个里面的代码很晚执行,执行时机在组件mounted周期之后