index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const Router = VueRouter;
  2. const routes = [
  3. //默认跳转到登录页
  4. {
  5. path: "/",
  6. redirect: "/loadingPage"
  7. },
  8. //loading
  9. {
  10. path: '/loadingPage',
  11. component: () => import('@/views/loadingPage/index'),
  12. hidden: true
  13. },
  14. //商品选择
  15. {
  16. path: '/good-share',
  17. component: () => import('@/views/good-share/index'),
  18. hidden: true
  19. },
  20. //方案选择
  21. {
  22. path: '/plan-change',
  23. component: () => import('@/views/plan-change/index'),
  24. hidden: true
  25. },
  26. //登录页
  27. {
  28. path: '/login',
  29. component: () => import('@/views/login/index'),
  30. hidden: true
  31. },
  32. //忘记密码
  33. {
  34. path: '/forget-password',
  35. component: () => import('@/views/login/forget-password'),
  36. hidden: true,
  37. noCache: true
  38. },
  39. ];
  40. console.log(process.env.BASE_URL);
  41. const router = new Router({
  42. mode: "hash",
  43. base: process.env.BASE_URL,
  44. scrollBehavior: () => ({ y: 0 }),
  45. routes
  46. });
  47. // 重写路由的push方法,主要是为了解决同一个路由路径重复点击报错
  48. const routerPush = Router.prototype.push;
  49. Router.prototype.push = function push(location) {
  50. return routerPush.call(this, location).catch(error => error);
  51. };
  52. Vue.use(Router);
  53. export default router;