根据天气api获取城市天气


 $(function () {
            var url = "https://www.tianqiapi.com/api/?version=v1&&cityid=101280301"; // 请求api地址
            $.ajax({
                type: 'get',
                url: url,
                dataType: 'json',
                async: false,
                success: function (data) {
                    var weathers= data.data;    // 获取返回内容中的data数据
                    if (weathers && weathers.length > 0) // 如果有值
                    {
                        var weather = weahters[0];  // 接口请求返回的数据有七天的数据,这里只取第一天的数据
                    }
                },
                error: function () {
                }
            })
        });

 

参考网址:

https://blog.csdn.net/qq_38832501/article/details/88384395

http://www.tianqiapi.com/?action=img

https://www.cnblogs.com/emo-Studio/p/6840534.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM