vue-cli3.0 需要自己去手动添加vue.config.js文件
//vue-cli 3.0中
devServer: {
port: 8080, // 端口号
host: 'localhost',
https: false, // https:{type:Boolean}
open: true, //配置自动启动浏览器
// proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理
proxy: {
'/api': {
target: 'http://localhost:3000',
ws: true,
changeOrigin: true
}
}, // 配置多个代理
}
//vue-cli 2.x dev中
proxyTable: {
'/api': {
target: 'http://localhost:3000/',
// pathRewrite: {
// '^/api': ''
// }
}
},