日期
|
天气状况
|
最高温度
|
最低温度
|
风力
|
空气质量
|
javascript
// script.jsconst weatherForecast = document.getElementById('weather-forecast');// 填写天气预报数据
const weatherData = [{date: '2023-03-08',condition: '晴',high: '18°',low: '8°',wind: '东南风 3-4 级',aqi: '优'},// 更多天气预报数据...
];// 将数据添加到表格中
weatherData.forEach(data => {const row = document.createElement('tr');const dateCell = document.createElement('td');dateCell.textContent = data.date;row.appendChild(dateCell);const conditionCell = document.createElement('td');conditionCell.textContent = data.condition;row.appendChild(conditionCell);const highCell = document.createElement('td');highCell.textContent = data.high;row.appendChild(highCell);const lowCell = document.createElement('td');lowCell.textContent = data.low;row.appendChild(lowCell);const windCell = document.createElement('td');windCell.textContent = data.wind;row.appendChild(windCell);const aqiCell = document.createElement('td');aqiCell.textContent = data.aqi;row.appendChild(aqiCell);weatherForecast.appendChild(row);
});