项目中调取高德地图天气接口

高德天气API

调取接口

axios
      .get(
        "https://restapi.amap.com/v3/weather/weatherInfo?city='城市编码'&key='用户key'"
      )
      .then((res) => {
        res.data.lives.forEach((ele) => {
          this.temperature = ele.temperature;
          this.weather = ele.weather
        });
      })
      .catch(console.log);

申请key时注意不要选择Web端(JS API)
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45906632/article/details/111404427