index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // //创建一个路由器
  2. import { createRouter, createWebHashHistory, } from "vue-router";
  3. import configurator from "@/view/configurator.vue"
  4. import resultLeft from '@/view/result/resultLeft.vue';
  5. import resultRight from '@/view/result/resultRight.vue';
  6. const home = () => import("@/views/home/index.vue")
  7. import result from '@/view/result.vue';
  8. const router = createRouter({
  9. history: createWebHashHistory(),
  10. routes: [
  11. {
  12. path: '/configurator',
  13. name:'模型库',
  14. component: configurator,// 这是路由的籁加载,也可以其他方式
  15. beforeEnter: (to, from,next) => {
  16. console.log(to, from);
  17. next()
  18. },
  19. },
  20. {
  21. path: '/vtk',
  22. name:'案例',
  23. component: () => import('@/view/vtk/vtk.vue'),// 这是路由的籁加载,也可以其他方式
  24. },
  25. {
  26. path: '/vtk2',
  27. name:'案例1',
  28. component: () => import('@/view/vtk/vtk2.vue'),// 这是路由的籁加载,也可以其他方式
  29. },
  30. {
  31. path: '/demo',
  32. name:'案例3',
  33. component: () => import('@/view/vtk/demo.vue'),// 这是路由的籁加载,也可以其他方式
  34. },
  35. // {
  36. // path: '/',
  37. // name:'首页',
  38. // component: () => import('@/view/home.vue'),
  39. // meta:{
  40. // keepAlive:false, // 需要缓存
  41. // title: '首页'
  42. // }
  43. // },
  44. {
  45. path: '/login',
  46. name: 'login',
  47. component: () => import('@/view/login.vue'), // 登录页面组件
  48. },
  49. {
  50. path: '/',
  51. name:'煤矿灾害态势推演',
  52. component: () => import('@/view/appmian.vue'),
  53. meta:{
  54. keepAlive:false, // 需要缓存
  55. title: '煤矿灾害态势推演'
  56. },
  57. children:[
  58. {
  59. path: '/home',
  60. name: 'home',
  61. component: () => import('@/views/home/index.vue'),
  62. }
  63. ]
  64. },
  65. // {
  66. // path: "/home",
  67. // name: "home",
  68. // component: home
  69. // },
  70. // {
  71. // path: '/home',
  72. // name:'局部',
  73. // component: () => import( "@/views/home/index.vue"),
  74. // meta:{
  75. // keepAlive:false, // 需要缓存
  76. // title: '局部'
  77. // },
  78. // },
  79. {
  80. path: '/goods',
  81. name: 'goods',
  82. component: {
  83. // 这里的 goods 对应 router-view 中的 name
  84. goods: resultLeft
  85. }
  86. },
  87. {
  88. path: '/orderinfo',
  89. name: 'orderinfo',
  90. component: {
  91. // 这里的 orderinfo 对应 router-view 中的 name
  92. orderinfo:resultRight
  93. }
  94. }
  95. // {
  96. // path: '/resultLeft',
  97. // name:'resultLeft',
  98. // component: resultLeft,// 这是路由的籁加载,也可以其他方式
  99. // },
  100. // {
  101. // path: '/resultRight',
  102. // name:'resultRight',
  103. // components:{
  104. // resultRight:resultRight
  105. // } // 这是路由的籁加载,也可以其他方式
  106. // },
  107. ]
  108. })
  109. //修改动态网页标题 beforeEach 导航钩子,路由改变前触发
  110. router.beforeEach((to,from,next) =>{
  111. //window.document.title = to.meta.title;
  112. window.document.title = to.name;
  113. next();
  114. })
  115. router.afterEach((to,from,next) =>{
  116. window.scrollTo(0,0);
  117. })
  118. export default router;