guonan
2025-04-14 9e860a560c5a4b81abe2042b8d8698e253730502
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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