From ad57243c3afa9cebec830cee77089c65bf3329d1 Mon Sep 17 00:00:00 2001
From: fanluyan <754122931@qq.com>
Date: Tue, 19 Nov 2024 15:48:42 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E5=85=BC?=
=?UTF-8?q?=E5=AE=B9=E4=BD=8E=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/index.html | 22 +++++++++++++++++-----
src/views/realTimeData/index.vue | 15 +++++++++++++--
2 files changed, 30 insertions(+), 7 deletions(-)
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));