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

fix: 解决新闻列表崩溃问题

上级 1c20c040
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</view> </view>
</template> </template>
<script> <script>
type Banner = { type Banner = {
cover: string | null, cover: string | null,
title: string | null, title: string | null,
...@@ -98,10 +98,12 @@ ...@@ -98,10 +98,12 @@
success: (data) => { success: (data) => {
if(this.pageVisible){ if(this.pageVisible){
if (data.statusCode == 200) { if (data.statusCode == 200) {
const result = data.data as UTSJSONObject const result = data.data as UTSJSONObject[]
let list = this.setTime(result); if(result != null){
this.listData = list.concat(this.listData); let list = this.setTime(result);
this.last_id = listData[0].id + ""; this.listData = list.concat(this.listData);
this.last_id = listData[0].id + "";
}
this.refresherTriggered = false; this.refresherTriggered = false;
} }
} }
...@@ -132,10 +134,10 @@ ...@@ -132,10 +134,10 @@
url: '/pages/component/list/detail/detail?post_id=' + post_id + "&cover=" + cover + "&title=" + title url: '/pages/component/list/detail/detail?post_id=' + post_id + "&cover=" + cover + "&title=" + title
}); });
}, },
setTime(items: UTSJSONObject): Item[] { setTime(items: UTSJSONObject[]): Item[] {
let newItems = [] as Item[]; let newItems = [] as Item[];
items.forEach((res)=>{ for(const item in items){
const e = res as UTSJSONObject; const e = item;
newItems.push({ newItems.push({
author_name: e["author_name"] as string, author_name: e["author_name"] as string,
cover: e["cover"] as string, cover: e["cover"] as string,
...@@ -144,7 +146,7 @@ ...@@ -144,7 +146,7 @@
published_at: e["published_at"] as string, published_at: e["published_at"] as string,
title: e["title"] as string title: e["title"] as string
} as Item); } as Item);
}); }
return newItems; return newItems;
}, },
onRefresherrefresh() { onRefresherrefresh() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册