前期准备
- axios
在工程文件夹根目录下新建vue.config.js
module.exports = {
devServer: {
port: 8080, // 源地址端口,自行修改
proxy: {
'/api': {
target: 'http://127.0.0.1:3000/', // 跨域目标主机,自行修改
ws: true, // 代理 websockets
changeOrigin: true,
pathRewrite: {
'^/api': '' // 重写地址
}
},
}
}
};