index.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * @description:
  3. * @Author: uray(1109489444@qq.com)
  4. * @date: 2022-04-13 17:15:34
  5. * @lastEditors: uray(1109489444@qq.com)
  6. * @lastEditTime: 2022-04-14 09:57:12
  7. * @FilePath: \toy_box_website\src\router\index.ts
  8. */
  9. import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
  10. // 1. 定义路由组件.
  11. // 也可以从其他文件导入
  12. import Detail from "../page/detail/index.vue";
  13. import Home from "../page/home/index.vue";
  14. // 2. 定义一些路由
  15. // 每个路由都需要映射到一个组件。
  16. // 我们后面再讨论嵌套路由。
  17. const routes: RouteRecordRaw[] = [
  18. { name: "home", path: "/page/home", component: Home },
  19. { name: "detail", path: "/page/detail", component: Detail },
  20. ];
  21. // 3. 创建路由实例并传递 `routes` 配置
  22. // 你可以在这里输入更多的配置,但我们在这里
  23. // 暂时保持简单
  24. const router = createRouter({
  25. // 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
  26. history: createWebHashHistory(),
  27. routes, // `routes: routes` 的缩写
  28. });
  29. export { router };