根据天气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

一分辛苦一分才
原文地址:https://www.cnblogs.com/JoanLin-workNotes/p/10959003.html