提交 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,8 +53,9 @@ ...@@ -53,8 +53,9 @@
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){
for(const res in jsonArr){
const json = res as UTSJSONObject; const json = res as UTSJSONObject;
const title = json["title"] as string; const title = json["title"] as string;
const subTitle = json["subTitle"] as string; const subTitle = json["subTitle"] as string;
...@@ -67,12 +68,13 @@ ...@@ -67,12 +68,13 @@
detail detail
} }
items.push(item); items.push(item);
}) }
let temp = [] as Item[]; let temp = [] as Item[];
for(let i = 0; i < 100; i++){ for(let i = 0; i < 100; i++){
temp = temp.concat(items); 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.
先完成此消息的编辑!
想要评论请 注册