vue3去掉地址栏里的# 只需要将原来默认的createWebhashHistory 改为createWebHistory即可.
import { createRouter, createWebHistory } from 'vue-router' import login from '../views/login.vue' import home from '../views/Home.vue' const routes = [ { path: '/', name: 'home', component: home }, { path: '/login', name: 'login', component: login } // }, // { // path: '/about', // name: 'About', // // route level code-splitting // // this generates a separate chunk (about.[hash].js) for this route // // which is lazy-loaded when the route is visited. // component: () => import(/* webpackChunkName: "about" */ '../views/About.vue') // } ] const router = createRouter({ history: createWebHistory(), routes }) export default router