index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. Vue.use(VueRouter)
  4. const routes = [
  5. {
  6. path: '/',
  7. name: 'home',
  8. component: () => import('../views/Home/index.vue'),
  9. meta: {
  10. myTitle: '徽韵江城'
  11. },
  12. },
  13. // 语音讲解
  14. {
  15. path: '/goods/audio',
  16. name: 'goodsAudio',
  17. component: () => import('../views/Goods/components/GoodsAudio.vue')
  18. },
  19. {
  20. path: '/layout',
  21. name: 'layout',
  22. component: () => import('../views/Layout/index.vue'),
  23. children: [{
  24. path: '/layout/construct',
  25. name: 'construct',
  26. meta: {
  27. myInd: 1,
  28. myTitle: '古建一张图'
  29. },
  30. component: () => import('../views/Construct/index.vue')
  31. },
  32. {
  33. path: '/layout/goods',
  34. name: 'goods',
  35. meta: {
  36. myInd: 1,
  37. },
  38. component: () => import('../views/Goods/index.vue')
  39. },
  40. {
  41. path: '/layout/construct',
  42. name: 'construct',
  43. meta: {
  44. myInd: 1,
  45. myTitle: '古建一张图'
  46. },
  47. component: () => import('../views/Construct/index.vue')
  48. },
  49. {
  50. path: '/layout/serve',
  51. name: 'serve',
  52. meta: {
  53. myInd: 2,
  54. myTitle: '享·服务',
  55. },
  56. component: () => import('../views/Serve/index.vue')
  57. },
  58. {
  59. path: '/layout/serve/recommended-path',
  60. name: 'RecommendedPath',
  61. meta: {
  62. myInd: 2,
  63. myTitle: '推荐路线',
  64. },
  65. component: () => import('../views/Serve/RecommendedPath.vue')
  66. },
  67. {
  68. path: '/layout/interact',
  69. name: 'interact',
  70. meta: {
  71. myInd: 3
  72. },
  73. component: () => import('../views/Interact/index.vue')
  74. },
  75. {
  76. path: '/layout/my',
  77. name: 'my',
  78. meta: {
  79. myInd: 4
  80. },
  81. component: () => import('../views/My/index.vue')
  82. }
  83. ]
  84. },
  85. ]
  86. const router = new VueRouter({
  87. routes
  88. })
  89. // 全局后置钩子,设置title
  90. router.afterEach(to => {
  91. // 设置title
  92. if (to.meta.myTitle) window.document.title = to.meta.myTitle;
  93. })
  94. export default router