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