index.ts 499 B

123456789101112131415161718
  1. import {createRouter, createWebHistory, RouteRecordRaw} from "vue-router";
  2. // 2. 配置路由
  3. const routes: Array<RouteRecordRaw> = [
  4. {
  5. name: "home",
  6. path: "/", component: () => import("../page/index.vue"),
  7. children: []
  8. },
  9. ];
  10. // 1.返回一个 router 实列,为函数,里面有配置项(对象) history
  11. const router = createRouter({
  12. history: createWebHistory(),
  13. routes,
  14. });
  15. // 3导出路由 然后去 main.ts 注册 router.ts
  16. export default router