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

fix: json遍历方式改变 ; 去掉Android平台专属的类型。

上级 93bcf092
......@@ -25,8 +25,6 @@
</template>
<script>
import JSONObject from 'com.alibaba.fastjson.JSONObject';
import JSONArray from 'com.alibaba.fastjson.JSONArray';
type Banner = {
cover: string | null,
title: string | null,
......@@ -40,8 +38,7 @@
published_at: string,
title: string
}
export default {
data() {
return {
......@@ -136,22 +133,19 @@
url: 'pages/component/list/detail/detail?post_id=' + post_id + "&cover=" + cover + "&title=" + title
});
},
setTime(items: UTSJSONObject): Item[] {
let newItems = [] as Item[];
if (items.isJSONArray()) {
const array = items.toJSONObject() as JSONArray;
for (let i = array.size - 1; i >= 0; i--) {
const e = array.get(i) as JSONObject;
newItems.push({
author_name: e["author_name"] as string,
cover: e["cover"] as string,
id: e["id"] as number,
post_id: e["post_id"] as string,
published_at: e["published_at"] as string,
title: e["title"] as string
} as Item);
}
}
setTime(items: UTSJSONObject): Item[] {
let newItems = [] as Item[];
items.forEach((res)=>{
const e = res as UTSJSONObject;
newItems.push({
author_name: e["author_name"] as string,
cover: e["cover"] as string,
id: e["id"] as number,
post_id: e["post_id"] as string,
published_at: e["published_at"] as string,
title: e["title"] as string
} as Item);
});
return newItems;
},
onRefresherrefresh() {
......@@ -159,7 +153,7 @@
this.refresherTriggered = true
this.getBanner();
this.getList();
}
}
}
}
};
......
......@@ -20,7 +20,6 @@
</template>
<script>
import JSONObject from 'com.alibaba.fastjson.JSONObject';
import { readFile, ReadFileOptions,ReadFileSuccessResult } from '@/uni_modules/uts-file-manager';
type Item = {
title: string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册