import { createRouter, createWebHistory } from 'vue-router' import $store from "@/store/index.js"; // 开启历史模式 // vue2中使用 mode: history 实现 const routerHistory = createWebHistory(); const router = createRouter({ history: routerHistory, routes: [{ path: "/", name: "main", component: () => import("../views/main.vue"), children: [ { //实现路由重定向,当进入网页时,路由自动跳转到/student路由 redirect: '/index', path: '/' }, { path: "/index", name: "index", component: () => import("../views/index/index.vue"), meta: { title: "" } }, { path: "/aboutus", name: "aboutus", component: () => import("../views/aboutus/index.vue"), meta: { title: "关于川印" } }, { path: "/qualification", name: "qualification", component: () => import("../views/aboutus/qualification.vue"), meta: { title: "资质认证" } }, { path: "/service", name: "service", component: () => import("../views/aboutus/service.vue"), meta: { title: "川印服务" } }, { path: "/development", name: "development", component: () => import("../views/aboutus/development.vue"), meta: { title: "发展规划" } }, { path: "/examination", name: "examination", component: () => import("../views/business/examination.vue"), meta: { title: "考试试卷" } }, { path: "/yiyuan", name: "yiyuan", component: () => import("../views/business/yiyuan.vue"), meta: { title: "医院印刷品" } }, { path: "/workbook", name: "workbook", component: () => import("../views/business/workbook.vue"), meta: { title: "作业簿册" } }, { path: "/assembly", name: "assembly", component: () => import("../views/business/assembly.vue"), meta: { title: "资料汇编" } },{ path: "/magazine", name: "magazine", component: () => import("../views/business/magazine.vue"), meta: { title: "期刊杂志" } },{ path: "/enrollment", name: "enrollment", component: () => import("../views/business/enrollment.vue"), meta: { title: "招生资料" } }, { path: "/other", name: "other", component: () => import("../views/business/other.vue"), meta: { title: "其它印刷品" } }, { path: "/servecustomers", name: "servecustomers", component: () => import("../views/servecustomers/index.vue"), meta: { title: "服务客户" } }, { path: "/equipment", name: "equipment", component: () => import("../views/equipment/index.vue"), meta: { title: "设备实力" } }, { path: "/join", name: "join", component: () => import("../views/join/index.vue"), meta: { title: "商务合作" } }, ] }, { path: "/tologin", name: "tologin", component: () => import("../views/login/index.vue"), meta: { title: "登录" } }] }, ) router.beforeEach((to, from, next) => { // console.log("to",to) // console.log("from",from) let crumblist = [{ name: from.meta.title, path: from.fullPath }, { name: to.meta.title, path: to.fullPath },] $store().setcrumb(crumblist) $store().sethdmen(to.path) // console.log("from", $store().crumb) next() }) export default router