此方法適用于
服務(wù)器配置: Allow-Control-Allow-Origin: *
客戶(hù)端配置:['Content-Type'] = 'application/x-www-form-urlencoded';
1:根目錄/config/index.js
proxyTable: {
'/api': {
target: 'https://api.map.baidu.com',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
}
2:引用 - (注意前綴(’/api/‘))
axios.get(`/api/geocoder/v2/callback=?`).then((response)=>{
var res = response.data;
console.log(res);
})