关于如何申请高德API我就不多说了
下面主要说一下代理的配置和访问
值得注意的是,端口号一定要设置成8080,否则会报错。
'/weather':{
port:8080,
target: 'https://restapi.amap.com/v3/weather',
secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, //是否跨域
pathRewrite: {
'^/weather': '/'
}
},
访问:
axios.get("/weather/weatherInfo?key=你自己的Key&city=110101")
.then(res=>{console.log(res.data);})
结果: