一、接口网址

接口文档:免费天气API接口|天气预报接口|全球天气API接口|气象预警|空气质量

用户中心:控制台 · 天气API

相关代码

       getWeather() {
            axios({
                url: 'https://www.tianqiapi.com/api/',
                method: "get",
                params: {
                    version: 'v1',
                    // city: '郑州',      // 若不提供城市名,会根据本机IP获取当地天气
                    appid: '******',      // 到该网站上注册申请
                    appsecret: '******'
                },
                headers: {
                    'Content-type':'application/x-www-form-urlencoded'
                },
                data: []
            }).then(res => {
                console.log(res.data);
                let todayData = res.data.data[0];
                console.log(todayData);
 
                ...... 
 
            });
        }

二、和风天气

开发文档:开始 | 和风天气开发平台

axios({
      url: 'https://devapi.qweather.com/v7/weather/now?location=101010100&key=你的key'
    }).then(res => {
      console.log(res.data)
    })

Logo

加入社区!打开量化的大门,首批课程上线啦!

更多推荐