vue嵌套路由

    {
      path: '/singer',
      name: 'singer',
      component: layout,
      redirect: '/singer/page',
      children: [
        {
          path: 'page',
          name: 'singerPage',
          component: () => import('@/views/singer'),
          children: [{
            path: ':id',
            component: ()=> import('@/components/singerDetail/singer-detail')
          }]
        }
      ]
    }

vuerouter
嵌套路由的时候子路由写在childrenvs ,path中无需添加/,添加后会被根路径

如果你的嵌套如上面代码,你在组件中

this.$router.push({
    path: '/singer/page/' + e.id
})

同时在singer组件中加上router-view 渲染组件

posted on 2019-10-08 17:06  2481  阅读(150)  评论(0编辑  收藏  举报

导航