JS——天气预报表格

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<table border="1"cellpadding="5" width="100%">
<tr><th>日期</th><th>日出</th><th>高温</th><th>低温</th><th>日落</th><th>空气质量</th><th>风向</th><th>风力</th><th>类型</th><th>小提示</th></tr>
<script type="text/javascript">

var air=[{
"date":"18日星期一",
"sunrise":"07:47",
"high":"高温 8.0℃",
"low":"低温 5.0℃",
"sunset":"18:23",
"aqi":65.0,
"fx":"无持续风向",
"fl":"<3级",
"type":"阴",
"notice":"灰蒙蒙的天空就像模糊了的眼睛"
},
{
"date":"19日星期二",
"sunrise":"07:47",
"high":"高温 9.0℃",
"low":"低温 2.0℃",
"sunset":"18:23",
"aqi":69.0,
"fx":"无持续风向",
"fl":"<3级",
"type":"多云",
"notice":"今日多云,骑上单车去看看世界吧",
},
{
"date":"20日星期三",
"sunrise":"07:48",
"high":"高温 11.0℃",
"low":"低温 1.0℃",
"sunset":"18:24",
"aqi":57.0,
"fx":"无持续风向",
"fl":"<3级",
"type":"晴",
"notice":"lovely sunshine,尽情享受阳光的温暖吧",
},
{
"date":"21日星期四",
"sunrise":"07:49",
"high":"高温 14.0℃",
"low":"低温 1.0℃",
"sunset":"18:24",
"aqi":58.0,
"fx":"无持续风向",
"fl":"<3级",
"type":"晴",
"notice":"天气干燥,请适当增加室内湿度",
},
{
"date":"22日星期五",
"sunrise":"07:49",
"high":"高温 14.0℃",
"low":"低温 3.0℃",
"sunset":"18:25",
"aqi":51.0,
"fx":"无持续风向",
"fl":"<3级",
"type":"晴",
"notice":"晴空万里,去沐浴阳光吧",
},
{ "date":"23日星期六",
"sunrise":"07:50",
"high":"高温 16.0℃",
"low":"低温 4.0℃",
"sunset":"18:25",
"aqi":56.0,
"fx":"无持续风向",
"fl":"<3级",
"type":"多云",
"notice":"悠悠的云里有淡淡的诗",
}
];
for(var i=0;i<air.length;i++){
document.write("<tr>");
for(var j in air[i]){
document.write("<td>"+air[i][j]+"</td>")
console.log(air[i][j])
}
document.write("</tr>")
}
</script>
</table>
</body>
</html>

原文地址:https://www.cnblogs.com/yan-linxi/p/8125910.html