《vue》router.push,params不生效问题

2021-07-29  本文已影响0人  BA_凌晨四点

情况1:

使用 push,跳转不能使用path,而是name

this.$router.push({
  name: 'test', // 这里不能是: path: '/test'
  query: { a: 123 }
})

情况2:

beforeEach这个钩子函数中不能获取 params以及query等!!!

所以一般在computed中拿 params:

computed: {
    myParams() {
      return this.$route.params;
    }
},
created() {
  console.log(this.myParams);
}
上一篇 下一篇

猜你喜欢

热点阅读