// 引入router的组件 import type { RouteRecordRaw } from "vue-router"; // 引入两个组件 import LoginView from "@/views/login/Index.vue" import DashboardView from "@/views/dashboard/Index.vue" import {createRouter, createWebHashHistory} from "vue-router"; // 2. 定义一些路由 // 每个路由都需要映射到一个组件。 // 我们后面再讨论嵌套路由。 const routes:Array = [ { path:'/', name : 'dashboard', component : DashboardView }, { path:'/login', name : 'login', component : LoginView } ] // 3. 创建路由实例并传递 `routes` 配置 // 你可以在这里输入更多的配置,但我们在这里 // 暂时保持简单 const router = createRouter({ // 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。 history: createWebHashHistory(), strict: true, // 按照严模式匹配 routes, // `routes: routes` 的缩写 scrollBehavior : () => ({ left:0, top:0 }) //跳转页面之后回到顶部 }) export default router // 导出路由