index.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { createRouter, createWebHistory } from 'vue-router'
  2. import HomeView from '../views/HomeView.vue'
  3. import NotFoundView from '../views/NotFoundView.vue'
  4. const router = createRouter({
  5. history: createWebHistory(import.meta.env.BASE_URL),
  6. routes: [
  7. {
  8. path: '/',
  9. name: 'home',
  10. component: HomeView,
  11. },
  12. {
  13. path: '/about',
  14. name: 'about',
  15. // route level code-splitting
  16. // this generates a separate chunk (About.[hash].js) for this route
  17. // which is lazy-loaded when the route is visited.
  18. component: () => import('../views/AboutView.vue'),
  19. },
  20. {
  21. path: '/news',
  22. name: 'news',
  23. component: () => import('../views/NewsView.vue'),
  24. },
  25. {
  26. path: '/introduction',
  27. name: 'introduction',
  28. component: () => import('../views/IntrodView.vue'),
  29. },
  30. {
  31. path: '/communicate',
  32. name: 'communicate',
  33. component: () => import('../views/CommunicateView.vue'),
  34. },
  35. {
  36. path: '/research',
  37. name: 'research',
  38. component: () => import('../views/ResearchView.vue'),
  39. },
  40. {
  41. path: '/404',
  42. name: 'NotFound',
  43. component: NotFoundView
  44. },
  45. {
  46. path: '/:pathMatch(.*)*', // 匹配所有不存在的路径
  47. redirect: '/404'
  48. }
  49. ],
  50. })
  51. export default router