webpack

proxy

vue-cli

config/index.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
module.exports = {
dev: {
// Paths
assetsSubDirectory: "static",
assetsPublicPath: "/",
proxyTable: {
"/api": {
target: "http://86.100.18.170:7070", //dp
pathRewrite: { "^/api": "" }
}
},
host: process.env.HOST,
port: 8080,
}

请求前需要加上 /api

1
2
3
const service = axios.create({
baseURL: '/api/', // api的base_url
})
本文结束,感谢您的阅读