# 路由配置

路由配置入口位于 src/router/index.js,了解 vue 的路由系统请参考 vue-router (opens new window)

路由目录中包含一个 modules 目录,它是子路由目录,用于将路由配置按照模块拆分,以免所有路由配置到一个文件中,导致需要维护一个过长的文件。

开发者可以在 modules 目录中根据需要创建自己的模块路由文件,例 customer.js。

打开路由目录的 index.js,通过 import 指令将 customer.js 引入到该文件中。

import customer from './modules/customer'
1

之后,可参考目前其中的 components 对象将引入的 customer 对象放到路由实例的合适位置。

路由的常用属性配置请参考 vue-element-admin 框架的文档 (opens new window)

# 路由示例

// 这是一个路由模块目录

// 请先忽略 Layout
import Layout from '@/layout'
const tableRouter = {
  path: '/table',
  component: Layout,
  redirect: '/table/complex-table',
  name: 'Table',
  meta: {
    title: 'Table',
    icon: 'table'
  },
  // 子路由
  children: [
    {
      path: 'common-table-demo',
      component: () => import('@/views/common-table-demo/demo'),
      name: 'common-table-demo',
      meta: { title: 'Common Table Demo' }
    }
  ]
}
export default tableRouter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
最后更新: 11/18/2021, 11:31:19 AM