From 736c67ef4792b714d35b3a85c818babedb0f9870 Mon Sep 17 00:00:00 2001 From: taohebin Date: Thu, 14 Sep 2023 18:00:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20forin=20=E6=94=B9=E4=B8=BAforEach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/long-list/long-list.uvue | 35 ++++++++++++------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/pages/component/long-list/long-list.uvue b/pages/component/long-list/long-list.uvue index 66c07957..732f4183 100644 --- a/pages/component/long-list/long-list.uvue +++ b/pages/component/long-list/long-list.uvue @@ -27,7 +27,7 @@ detail: string, } - + export default { data() { return { @@ -55,20 +55,19 @@ const items = [] as Item[]; 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); - } + jsonArr.forEach((json) => { + 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); + }) let temp = [] as Item[]; for(let i = 0; i < 100; i++){ temp = temp.concat(items); @@ -80,7 +79,7 @@ },0); }, complete:function(_){ - + } } as ReadFileOptions) }, @@ -128,9 +127,9 @@ display: flex; margin-top: 10rpx; } - + .uni-media-list-text { color: #9D9D9F; font-size: 25rpx; } - \ No newline at end of file + -- GitLab