将hase模式改为history模式即可
import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
// mode: "history",
history: createWebHistory(),
routes: [
//...
],
})
history模式刷新界面就会404
需要在ngnix加入以下内容
location / {
try_files $uri $uri/ /index.html;
}
我是宝塔部署到所有在项目的设置》配置文件,然后加上以上代码即可
最后是官网地址 https://router.vuejs.org/zh/guide/essentials/history-mode.html