🐛 轻雪天气获取空aqi值的异常错误

This commit is contained in:
2024-04-29 16:58:52 +08:00
parent c063c69dea
commit 8809459f1b
7 changed files with 26 additions and 15 deletions

View File

@ -28,15 +28,21 @@ let locationData = data["location"]
// 处理aqi
let aqiValue = 0
aqi["aqi"].forEach(
(item) => {
if (item["defaultLocalAqi"]) {
document.getElementById("aqi-data").innerText = "AQI " + item["valueDisplay"] + " " + item["category"]
// 将(255,255,255)这种格式的颜色设置给css
document.getElementById("aqi-dot").style.backgroundColor = "rgb(" + item["color"] + ")"
if ("aqi" in aqi) {
aqi["aqi"].forEach(
(item) => {
if (item["defaultLocalAqi"]) {
document.getElementById("aqi-data").innerText = "AQI " + item["valueDisplay"] + " " + item["category"]
// 将(255,255,255)这种格式的颜色设置给css
document.getElementById("aqi-dot").style.backgroundColor = "rgb(" + item["color"] + ")"
}
}
}
)
)
} else {
document.getElementById("aqi-dot").style.backgroundColor = '#fff'
document.getElementById("aqi-data").innerText = localData['no_aqi']
}
templates = {
"time": weatherNow["now"]["obsTime"],
@ -92,7 +98,7 @@ weatherDaily['daily'].forEach(
return
}
let today = days[index]
if (index >= 2){
if (index >= 2) {
today += `(${item["fxDate"].split("-")[1]}.${item["fxDate"].split("-")[2]})`
}
let dailyItemDiv = document.importNode(document.getElementById("daily-item-template").content, true)