$(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