解决方案:
1、路由模式使用hash替换history
// mode: 'history',
mode:history注释掉,路由默认使用hash模式
2、在vue.config.js中配置publicPath
module.exports = defineConfig({
transpileDependencies: true,
devServer:{
port:8080,
proxy:{
'/api':{
target:'http:xxx', //自定义请求的接口
changeOrigin:true, //允许跨域
pathRewrite:{
'^/api':''
}
}
},
// useLocalIp: true,
},
publicPath:'./'
})