後臺在向前臺返回數據時肯定是以分頁的形式來返回的,很少會有直接一坨都全部返回給前臺。那麼前臺就需要分頁的去接收來自後臺的數據。
ST裏面的listpaging組件就是用來做分頁的,它在頁面最下方添加了一個‘load more‘的按鈕,點擊的時候會自動將下一頁的數據加載進相對應的store,並且可以的話會在對應的位置顯示出來。
使用listPaging進行分頁顯示的方法,重寫了裏面的nextPage的函數:
nextPage: function(options) {
if(this.currentPage2 == null) {
this.currentPage2 = 1;
}
this.currentPage2 = this.currentPage2 + 1;
this._proxy._url = 'http://121.199.60.94/picourse/index.php/HighCourse/getHighCourseByPage/page_num/'+this.currentPage2;
this.loadPage(1, options);
}
親測可以,不過對於ST中的options還是有一些困惑。