vue路由跳转总是跳转到首页,路由匹配不上

1.先看路由配置文件:

    {
      path: 'detail/:No',
      name: 'waybill-declaration-detail',
      component: () => import('@/views/wayb/Detail'),
      meta: {
        redirect: true,
        title: '运单'
      }
    }

2.编写跳转事件

click: () => {
                this.$router.push({
                   name: 'waybill-declaration-detail',
            }

 这样跳转是匹配不上的,如果做了路由为空跳转的到首页, 那么本次跳转就会跳到首页。

注意:上面的路由配置的path,里面的参数No是动态的,但是参数会加到路由上去,

所以,事件里面也要加上参数No,需要全匹配

3.正确写法

click: () => {
             this.$router.push({
                name: 'waybill-declaration-detail',
                params: {
                  No:2323
                }
              })
        }

猜你喜欢

转载自blog.csdn.net/weixin_39818813/article/details/109992090