index.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";
  2. // 2. 配置路由
  3. var routes: Array<RouteRecordRaw> = [
  4. {
  5. name: "home",
  6. path: "/",
  7. component: () => import("../page/Home.vue"),
  8. children: []
  9. },
  10. {
  11. name: "detail",
  12. path: "/detail",
  13. component: () => import("../page/DetailPage.vue"),
  14. children: [
  15. {
  16. name: "detail",
  17. path: "/detail/:path(.*)",
  18. component: () => import("../page/DetailPage.vue")
  19. }
  20. ]
  21. },
  22. {
  23. name: "info",
  24. path: "/info",
  25. component: () => import("../page/Info.vue"),
  26. children: [
  27. {
  28. name: "login",
  29. path: "/info/:path(.*)",
  30. component: () => import("../page/Info.vue")
  31. }
  32. ]
  33. }
  34. ];
  35. // 1.返回一个 router 实列,为函数,里面有配置项(对象) history
  36. const router = createRouter({
  37. history: createWebHistory(),
  38. routes,
  39. });
  40. // 3导出路由 然后去 main.ts 注册 router.ts
  41. export default router