createWebHistory
函数是有一个参数的,可以添加一个路径,如下:
const router = createRouter({
history: createWebHistory('welcome'),
routes
});
那么我们对应的输出网址为: https://xxx.com/welcome/
。
刷新找不到资源 原本config.js 的publicpath(我这里是vite.config.js
base: './',
怀疑是相对路径配置刷新找不到资源 改成与绝对路径
base: '/welcome', // 设置打包路径
刷新可看到页面,修复!