index.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
  4. // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
  5. Vue.use(Router)
  6. /* Layout */
  7. import Layout from '../views/layout/Layout'
  8. /**
  9. * hidden: true if `hidden:true` will not show in the sidebar(default is false)
  10. * alwaysShow: true if set true, will always show the root menu, whatever its child routes length
  11. * if not set alwaysShow, only more than one route under the children
  12. * it will becomes nested mode, otherwise not show the root menu
  13. * redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb
  14. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  15. * meta : {
  16. title: 'title' the name show in submenu and breadcrumb (recommend set)
  17. icon: 'svg-name' the icon show in the sidebar,
  18. }
  19. **/
  20. export const constantRouterMap = [
  21. { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  22. { path: '/404', component: () => import('@/views/404'), hidden: true },
  23. {
  24. path: '/',
  25. component: Layout,
  26. redirect: '/dashboard',
  27. name: 'Dashboard',
  28. hidden: true,
  29. children: [{
  30. path: 'dashboard',
  31. component: () => import('@/views/dashboard/index')
  32. }]
  33. },
  34. {
  35. path: '/example',
  36. component: Layout,
  37. redirect: '/example/table',
  38. name: 'Example',
  39. meta: { title: 'Example', icon: 'example' },
  40. children: [
  41. {
  42. path: 'table',
  43. name: 'Table',
  44. component: () => import('@/views/table/index'),
  45. meta: { title: 'Table', icon: 'table' }
  46. },
  47. {
  48. path: 'tree',
  49. name: 'Tree',
  50. component: () => import('@/views/tree/index'),
  51. meta: { title: 'Tree', icon: 'tree' }
  52. }
  53. ]
  54. },
  55. {
  56. path: '/form',
  57. component: Layout,
  58. children: [
  59. {
  60. path: 'index',
  61. name: 'Form',
  62. component: () => import('@/views/form/index'),
  63. meta: { title: 'Form', icon: 'form' }
  64. }
  65. ]
  66. },
  67. { path: '*', redirect: '/404', hidden: true }
  68. ]
  69. export default new Router({
  70. // mode: 'history', //后端支持可开
  71. scrollBehavior: () => ({ y: 0 }),
  72. routes: constantRouterMap
  73. })