index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. const Router = VueRouter;
  2. const routes = [
  3. //默认跳转到登录页
  4. {
  5. path: "/",
  6. redirect: "/login"
  7. },
  8. //默认跳转到登录页
  9. {
  10. path: '/login',
  11. component: () => import('@/views/login/index'),
  12. hidden: true
  13. },
  14. {
  15. path: '/home',
  16. component: () => import('@/layout/index'),
  17. redirect: '/paddy',
  18. children: [
  19. {
  20. path: 'paddy',
  21. component: () => import('@/views/paddy/index'),
  22. name: 'paddy',
  23. alwaysShow: true,
  24. meta: { title: '稻田', noCache: true, breadcrumb: true }
  25. },
  26. {
  27. path: 'product',
  28. component: () => import('@/views/product/index'),
  29. name: 'product',
  30. alwaysShow: true,
  31. meta: { title: '产品', noCache: true, breadcrumb: true }
  32. },
  33. {
  34. path: 'my',
  35. component: () => import('@/views/my/index'),
  36. name: 'my',
  37. alwaysShow: true,
  38. meta: { title: '我的', noCache: true, breadcrumb: true }
  39. },
  40. ]
  41. },
  42. {
  43. path: '/orderRes',
  44. component: () => import('@/views/order/orderRes'),
  45. hidden: true
  46. },
  47. {
  48. path: '/liveD',
  49. component: () => import('@/views/live/liveD'),
  50. hidden: true
  51. },
  52. {
  53. path: '/address',
  54. component: () => import('@/views/address/index'),
  55. hidden: true
  56. },
  57. {
  58. path: '/addressView',
  59. component: () => import('@/views/address/view'),
  60. hidden: true
  61. },
  62. {
  63. path: '/live',
  64. component: () => import('@/views/live/index'),
  65. hidden: true
  66. },
  67. {
  68. path: '/order',
  69. component: () => import('@/views/order/index'),
  70. hidden: true
  71. },
  72. {
  73. path: '/oDetail',
  74. component: () => import('@/views/order/detail'),
  75. hidden: true
  76. },
  77. {
  78. path: '/aboutUs',
  79. component: () => import('@/views/aboutUs/index'),
  80. hidden: true
  81. },
  82. ];
  83. console.log(process.env.BASE_URL);
  84. const router = new Router({
  85. mode: "hash",
  86. base: process.env.BASE_URL,
  87. scrollBehavior: () => ({ y: 0 }),
  88. routes
  89. });
  90. // 重写路由的push方法,主要是为了解决同一个路由路径重复点击报错
  91. const routerPush = Router.prototype.push;
  92. Router.prototype.push = function push(location) {
  93. return routerPush.call(this, location).catch(error => error);
  94. };
  95. Vue.use(Router);
  96. export default router;