From 9ff41b94fea70fde64ab9c26533d890f11951ef4 Mon Sep 17 00:00:00 2001 From: taohebin Date: Mon, 14 Aug 2023 18:19:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=82=E9=85=8Djson=E7=9A=84=E5=8F=98?= =?UTF-8?q?=E5=8A=A8=EF=BC=8C=E6=B6=88=E9=99=A4=E7=BC=96=E8=AF=91=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../get-app-base-info/get-app-base-info.uvue | 2 +- .../API/get-device-info/get-device-info.uvue | 2 +- .../API/get-system-info/get-system-info.uvue | 2 +- .../API/get-window-info/get-window-info.uvue | 2 +- pages/component/long-list/long-list.uvue | 38 ++++++++++--------- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/pages/API/get-app-base-info/get-app-base-info.uvue b/pages/API/get-app-base-info/get-app-base-info.uvue index 5fd302ee..4d603059 100644 --- a/pages/API/get-app-base-info/get-app-base-info.uvue +++ b/pages/API/get-app-base-info/get-app-base-info.uvue @@ -41,7 +41,7 @@ const json = JSON.stringify(res); const result = JSON.parse>(json); this.items = [] as Item[]; - result.forEach((value, key) => { + result?.forEach((value, key) => { const item = { label: key, value: "" + value diff --git a/pages/API/get-device-info/get-device-info.uvue b/pages/API/get-device-info/get-device-info.uvue index 9f64d3d3..69f3bdbc 100644 --- a/pages/API/get-device-info/get-device-info.uvue +++ b/pages/API/get-device-info/get-device-info.uvue @@ -60,7 +60,7 @@ export default { const json = JSON.stringify(res); const result = JSON.parse>(json); this.items = [] as Item[]; - result.forEach((value, key) => { + result?.forEach((value, key) => { const item = { label: key, value: "" + value diff --git a/pages/API/get-system-info/get-system-info.uvue b/pages/API/get-system-info/get-system-info.uvue index 62bfa7c3..7acbba04 100644 --- a/pages/API/get-system-info/get-system-info.uvue +++ b/pages/API/get-system-info/get-system-info.uvue @@ -61,7 +61,7 @@ export default { const json = JSON.stringify(res); const result = JSON.parse>(json); this.items = [] as Item[]; - result.forEach((value, key) => { + result?.forEach((value, key) => { const item = { label: key, value: "" + value diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue index 75b1d8aa..42ffd05d 100644 --- a/pages/API/get-window-info/get-window-info.uvue +++ b/pages/API/get-window-info/get-window-info.uvue @@ -41,7 +41,7 @@ const json = JSON.stringify(res); const result = JSON.parse>(json); this.items = [] as Item[]; - result.forEach((value, key) => { + result?.forEach((value, key) => { const item = { label: key, value: "" + value diff --git a/pages/component/long-list/long-list.uvue b/pages/component/long-list/long-list.uvue index 0f43351c..ddd4132a 100644 --- a/pages/component/long-list/long-list.uvue +++ b/pages/component/long-list/long-list.uvue @@ -53,26 +53,28 @@ success:function(result){ const content = result.data; const items = [] as Item[]; - const jsonArr = JSON.parse(content); - jsonArr?.forEach((res)=>{ - const json = res as UTSJSONObject; - const title = json["title"] as string; - const subTitle = json["subTitle"] as string; - const img = json["img"] as string; - const detail = json["detail"] as string; - const item:Item = { - title, - subTitle, - img, - detail + const jsonArr = JSON.parse>(content); + if(jsonArr != null){ + for(const res in jsonArr){ + const json = res as UTSJSONObject; + const title = json["title"] as string; + const subTitle = json["subTitle"] as string; + const img = json["img"] as string; + const detail = json["detail"] as string; + const item:Item = { + title, + subTitle, + img, + detail + } + items.push(item); } - items.push(item); - }) - let temp = [] as Item[]; - for(let i = 0; i < 100; i++){ - temp = temp.concat(items); + let temp = [] as Item[]; + for(let i = 0; i < 100; i++){ + temp = temp.concat(items); + } + listData = temp; } - listData = temp; setTimeout(()=>{ this.refresherTriggered = false },0); -- GitLab