【发布时间】:2015-02-05 05:48:52
【问题描述】:
我正在使用 simpleweather.js 成功呈现天气更新,并试图让预报图标出现在预报日旁边。
使用:
$(document).ready(function() {
$.simpleWeather({
location: 'Melborune, Australia',
unit: 'c',
success: function(weather) {
html = '<h2><i class="icon-'+weather.code+'"></i>'+weather.temp+'°'+weather.units.temp+'</h2>';
html += '<ul><li><i style="color:#000" class="icon-'+weather.code+'"></i>'+weather.city+', '+weather.region+'</li>';
html += '<li class="currently">'+weather.currently+'</li>';
html += '<li>'+weather.alt.temp+'°C</li></ul>';
for(var i=0;i<weather.forecast.length;i++) {
html += '<p><i style="color:#000" class="icon-'+weather.code+'"></i>'+weather.forecast[i].day+': '+weather.forecast[i].high+'</p>';
}
$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
});
我可以四处走动,它会显示当前温度的图标,但我不知道预测天数的图标代码是什么。
对不起,我对使用 API 很陌生。任何帮助将不胜感激。
【问题讨论】: