{
"count": 87,
"next": "http://127.0.0.1:5000/api/v1.0/posts/?page=2",
"posts": [
{
"author": "http://127.0.0.1:5000/api/v1.0/users/2",
"body": "\u66f4\u597d\u6591\u6591\u9a73\u9a73\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d\u4e0d",
"body_html": null,
"body_title": null,
"comment_count": 0,
"comments": "http://127.0.0.1:5000/api/v1.0/posts/1/comments/",
"id": 1,
"timestamp": "Wed, 24 Jun 2015 06:40:03 GMT",
"url": "http://127.0.0.1:5000/api/v1.0/posts/1"
},
{
"author": "http://127.0.0.1:5000/api/v1.0/users/2",
"body": "\u770b\u770b\u770b\u770b\u5361\u5361\u5361\u5361\u9760\u9760\u9760\u9760\u9760\u9760\u9760",
"body_html": null,
"body_title": null,
"comment_count": 0,
"comments": "http://127.0.0.1:5000/api/v1.0/posts/2/comments/",
"id": 2,
"timestamp": "Wed, 24 Jun 2015 06:40:31 GMT",
"url": "http://127.0.0.1:5000/api/v1.0/posts/2"
},
{
"author": "http://127.0.0.1:5000/api/v1.0/users/2",
"body": "uuuuuuuuuuuuuuuuuuu\u6de1\u6de1\u7684\u6de1\u6de1\u7684\u6de1\u6de1\u7684\u6de1\u6de1\u7684\u6de1\u6de1\u7684\u6de1\u6de1\u7684\u6de1\u6de1\u7684",
"body_html": null,
"body_title": null,
"comment_count": 0,
"comments": "http://127.0.0.1:5000/api/v1.0/posts/3/comments/",
"id": 3,
"timestamp": "Wed, 24 Jun 2015 06:40:44 GMT",
"url": "http://127.0.0.1:5000/api/v1.0/posts/3"
}
],
"prev": null
}
请问怎样通过这样的JSON数据,实现下拉刷新加载更多,是要判断id吗?还是创建时间?或者输出怎样的JSON数据更方便一些?
大家讲道理2017-04-17 15:03:51
next
欄位可以不需要,客戶端可以透過count
欄位計算下一次請求的頁碼。 count
欄位只需要在取得第一頁資料時回傳。
下拉刷新
:清空本地所有數據,載入第一頁。 上拉加载
:使用目前頁碼載入資料。 下拉刷新
和上拉加载
載入網路資料成功後的共同邏輯:載入成功後透過count
和取得到的資料總條數對比,如果還有數據,那麼页码变量
要加一。 下拉刷新上拉加載有一個很好用的庫推薦https://github.com/CoderMJLee/MJRefresh