直接上代码, 在配置文件中添加跨域转发
devServer: {
historyApiFallback: true,
noInfo: true,
hot: true,
inline: true,
port: 8899,
proxy: {
'/helloPro': { // 在method中直接用 /helloPro 会替换 target指向的地址.
target: 'http://localhost:8080/helloPro', // 这里一定要加上http://
changeOrigin: true, //启用跨域
secure: false
}
}
},