import { createRouter, createWebHashHistory } from "vue-router" const routes = [ { path: "/", name: "home", // component: () => import("../views/Home.vue"), }, { path: "/yhgl", name: "yhgl", component: () => import("../views/yhgl.vue"), }, { path: "/zhjc", name: "zhjc", component: () => import("../views/zhjc.vue"), }, { path: "/mnfz", name: "mnfz", component: () => import("../views/mnfz.vue"), }, { path: "/mnpg", name: "mnpg", component: () => import("../views/mnpg.vue"), }, ] const router = createRouter({ history: createWebHashHistory(process.env.BASE_URL), routes, }) router.beforeEach((to, from, next) => { if (from.name === undefined && to.path !== '/') { // 如果是刷新页面且不是首页,则重定向 next('/') } else { next() } }) export default router