我想使用百度地图的逆地理编码API,于是注册了百度账号并且建立了一个应用,如下图:
当我使用axios去请求的时候,报跨域错误
axios.get('http://api.map.baidu.com/geocoder/v2/', {
params: {
ak: '', // 此处是密钥
location: e.point.lat + ',' + e.point.lng
}
}).then(res => {
console.log(res)
})
跨域错误:
Access to XMLHttpRequest at 'http://api.map.baidu.com/geoc...' from origin 'http://test.lalei.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
为了安全起见,ak没写出来哈
用jsonp