index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. Vue.use(VueRouter)
  4. const originalPush = VueRouter.prototype.push
  5. VueRouter.prototype.push = function push(location) {
  6. return originalPush.call(this, location).catch(err => err)
  7. }
  8. const routes = [
  9. {
  10. path: "/",
  11. component: () => import('@/views/index'),
  12. },
  13. // {
  14. // path:'/login',
  15. // name:'Login',
  16. // meta: {
  17. // title: '系统登录'
  18. // },
  19. // component: () => import("@/views/login/index.vue")
  20. // },
  21. {
  22. path: "",
  23. component: () => import('@/views/layout/index.vue'),
  24. children: [
  25. {
  26. path: '/home',
  27. name: 'Home',
  28. meta: {
  29. // title: '首页',
  30. sign: 'home',
  31. belong: 'home'
  32. },
  33. component: () => import('@/views/home/index.vue'),
  34. },
  35. ]
  36. }
  37. ]
  38. const router = new VueRouter({
  39. mode: 'history',
  40. base: '/',
  41. routes
  42. })
  43. router.beforeEach((to, from, next) => {
  44. if (to.meta.title) {
  45. document.title = to.meta.title;
  46. }
  47. next();
  48. })
  49. router.afterEach((to, from) => {
  50. });
  51. export default router