1、配置vue.config.js
module.exports = {
// 关闭线上源码
productionSourceMap: true,
devServer: {
disableHostCheck: true,
open: true,
port: 8001,
https: false,
hotOnly: false,
proxy: {
'/api': {
target: "后端ip地址",
changeOrigin: true, //允许跨域
pathRewrite:{
'^/api': '/'
},
},
},
},
}