diff --git a/public/index.html b/public/index.html index 3e5a1396..2054e378 100644 --- a/public/index.html +++ b/public/index.html @@ -1,15 +1,27 @@ - - - - + + + + + + + + + <%= htmlWebpackPlugin.options.title %>
diff --git a/src/views/realTimeData/index.vue b/src/views/realTimeData/index.vue index d3ef8568..7f092de0 100644 --- a/src/views/realTimeData/index.vue +++ b/src/views/realTimeData/index.vue @@ -283,7 +283,14 @@ export default { this.deviceTitle = JSON.parse(deviceInfoVal); } else { // 否则,使用 res.data[0].id - this.deviceTypeVal = res.data[0]?.id; // 使用可选链操作符避免 res.data[0] 为 undefined 的情况 + //this.deviceTypeVal = res.data[0]?.id; // 使用可选链操作符避免 res.data[0] 为 undefined 的情况 低版本不认识 + this.deviceTypeVal = + res.data && + Array.isArray(res.data) && + res.data.length > 0 && + res.data[0] !== null + ? res.data[0].id + : undefined; this.deviceTitle = res.data[0].mc; // 同时,将新获取的 areaVal 存储到 localStorage 中 localStorage.setItem( @@ -368,7 +375,11 @@ export default { this.areaVal = JSON.parse(storedAreaVal); } else { // 否则,使用 res.data[0].id - this.areaVal = res.data[0]?.id; // 使用可选链操作符避免 res.data[0] 为 undefined 的情况 + + this.areaVal = + res.data && res.data.length > 0 && res.data[0] !== null + ? res.data[0].id + : undefined; // 同时,将新获取的 areaVal 存储到 localStorage 中 localStorage.setItem("areaVal", JSON.stringify(this.areaVal));