1.路由改造 --vue
不要使用 history 路由模式
使用hash模式(url发生变化时,变化的是url的#号后面的hash值)
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/72b518cd86e04d34817d4eafd922ffb2.png
2.请求改造
let windowBaseUrl: () => string = () => {
let baseUrl = window.location.origin !== 'null' ? `${window.location.origin}${window.location.pathname}` : '';
return baseUrl.replace(/\/[^\/]*.html/, '').replace(/\/+$/, '')
};
在axios 封装文件中配置baseURL
baseURL: windowBaseUrl(),
- 配置打包的公共基础路径 --vite
‘/’ 是基于根目录下的绝对路径,'./'是相对路径 会自动拼接前缀
base: ‘./’