deactivated和beforeRouteLeave中this.$route.path的区别

场景:四个一级路由,当从about跳转到profile的时候,控制台打印this.$route.path,观察二者的区别

1. beforeRouteLeave

beforeRouteLeave (to, from, next) {
    console.log(this.$route.path)
    next()
  }

当从about跳转到profile的时候打印this.$route.path如下

可以看出:此时 this.$route.path中保存的是跳转前的路径

2. deactivated

deactivated(){
    console.log(this.$route.path);
  }

当从about跳转到profile的时候打印this.$route.path如下

 可以看出:此时 this.$route.path中保存的是跳转后的路径

猜你喜欢

转载自blog.csdn.net/a1059526327/article/details/109205719