vue 访问二级路由时默认自动跳转指定的三级路由页面

2021-07-08 10:12:47 浏览数 (3)

在二级路由配置redirect:'/reconciliation/list',也就是增加个redirect的指向就可以了

示例代码:

代码语言:javascript复制
const admin = [
  {
    path: '/',
    name: 'index',
    component: (resolve) => require(['@/page/index'], resolve),
    children: [
      {
        path: '/',
        redirect: 'fixManage'
      },
      {
        path: '/fixManage',
        name: 'fixManage',
        meta: {title: '推修管理', auth: false},
        component: (resolve) => require(['@/page/fixManage'], resolve),//映射的组件
      },
      {
        path: '/reconciliation', //二级路由
        name: 'reconciliation',
        meta: {title: '对账结算'},
        redirect:'/reconciliation/list',
        component: (resolve) => require(['@/page/reconciliation'], resolve),//映射的组件
        children: [
          {//三级路由
            path: 'list',
            name: 'reconciliationList',
            meta: {activeName: 'reconciliation'},
            component: resolve => require(['@/page/reconciliation/list'], resolve)
          },
          {
            path: 'fix',
            name: 'reconciliationFix',
            meta: {activeName: 'reconciliation'},
            component: resolve => require(['@/page/reconciliation/reconciliationFix'], resolve)
          },
        ]
      }
    ]
  },

  {
    path: '/list',
    name: 'list',
    component: (resolve) => require(['@/page/list'], resolve),//映射的组件
    meta: {title: 'list'}
  },
  {
    path: '/login',
    name: 'login',
    component: (resolve) => require(['@/page/login'], resolve),//映射的组件
    meta: {title: 'login'}
  }
]

1 人点赞