vue-router:按名称和参数导航到嵌套状态/路由

时间:2018-10-24 20:06:59

标签: vue.js vue-router

如何使用$router.push导航到子状态?

我的路线:

const routes = [
  {
    path: "/customers", name: 'Customers',
    components: {content: CustomersMain},
    props: {header: true, content: false},
    children: [
      {
        path: '',
        component: CustomerDetailsEmpty
      },
      {
        path: ':id',
        name: 'CustomerDetails',
        component: CustomerDetails
      }
    ]
  }
];

如何使用设置为CustomerDetails的参数导航到id $router.push

1 个答案:

答案 0 :(得分:2)

这可以解决问题:

this.$router.push({ name: `CustomerDetails`, params: {id} });