提交 9ff41b94 编写于 作者: taohebin@dcloud.io's avatar taohebin@dcloud.io

fix: 适配json的变动,消除编译报错。

上级 cab95603
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
const json = JSON.stringify(res); const json = JSON.stringify(res);
const result = JSON.parse<Map<string, any>>(json); const result = JSON.parse<Map<string, any>>(json);
this.items = [] as Item[]; this.items = [] as Item[];
result.forEach((value, key) => { result?.forEach((value, key) => {
const item = { const item = {
label: key, label: key,
value: "" + value value: "" + value
......
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
const json = JSON.stringify(res); const json = JSON.stringify(res);
const result = JSON.parse<Map<string, any>>(json); const result = JSON.parse<Map<string, any>>(json);
this.items = [] as Item[]; this.items = [] as Item[];
result.forEach((value, key) => { result?.forEach((value, key) => {
const item = { const item = {
label: key, label: key,
value: "" + value value: "" + value
......
...@@ -61,7 +61,7 @@ export default { ...@@ -61,7 +61,7 @@ export default {
const json = JSON.stringify(res); const json = JSON.stringify(res);
const result = JSON.parse<Map<string, any>>(json); const result = JSON.parse<Map<string, any>>(json);
this.items = [] as Item[]; this.items = [] as Item[];
result.forEach((value, key) => { result?.forEach((value, key) => {
const item = { const item = {
label: key, label: key,
value: "" + value value: "" + value
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
const json = JSON.stringify(res); const json = JSON.stringify(res);
const result = JSON.parse<Map<string, any>>(json); const result = JSON.parse<Map<string, any>>(json);
this.items = [] as Item[]; this.items = [] as Item[];
result.forEach((value, key) => { result?.forEach((value, key) => {
const item = { const item = {
label: key, label: key,
value: "" + value value: "" + value
......
...@@ -53,26 +53,28 @@ ...@@ -53,26 +53,28 @@
success:function(result){ success:function(result){
const content = result.data; const content = result.data;
const items = [] as Item[]; const items = [] as Item[];
const jsonArr = JSON.parse(content); const jsonArr = JSON.parse<Array<UTSJSONObject>>(content);
jsonArr?.forEach((res)=>{ if(jsonArr != null){
const json = res as UTSJSONObject; for(const res in jsonArr){
const title = json["title"] as string; const json = res as UTSJSONObject;
const subTitle = json["subTitle"] as string; const title = json["title"] as string;
const img = json["img"] as string; const subTitle = json["subTitle"] as string;
const detail = json["detail"] as string; const img = json["img"] as string;
const item:Item = { const detail = json["detail"] as string;
title, const item:Item = {
subTitle, title,
img, subTitle,
detail img,
detail
}
items.push(item);
} }
items.push(item); let temp = [] as Item[];
}) for(let i = 0; i < 100; i++){
let temp = [] as Item[]; temp = temp.concat(items);
for(let i = 0; i < 100; i++){ }
temp = temp.concat(items); listData = temp;
} }
listData = temp;
setTimeout(()=>{ setTimeout(()=>{
this.refresherTriggered = false this.refresherTriggered = false
},0); },0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册