import{_ as s,c as i,o as a,aj as n}from"./chunks/framework.DNhrqZu5.js";const g=JSON.parse('{"title":"vue-router","description":"","frontmatter":{},"headers":[],"relativePath":"guide/vue3/router.md","filePath":"guide/vue3/router.md","lastUpdated":1756280955000}'),t={name:"guide/vue3/router.md"},e=n(`
本案例采用 hash
模式,开发者根据需求修改 mode
base
注意:如果你使用了 history
模式, vue.config.js
中的 publicPath
要做对应的修改
import Vue from "vue";
import { createRouter, createWebHistory, Router } from "vue-router";
Vue.use(Router);
export const router = [
{
name: "root",
path: "/",
redirect: "/home",
component: () => import("@/layout/basic/index.vue"),
},
];
const router: Router = createRouter({
history: createWebHistory(),
routes: routes,
});
export default router;