您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)怎么在微信小程序中實(shí)現(xiàn)一個(gè)下滑到底部自動翻頁功能,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。
wxml:
<scroll-view class="scroll_view" scroll-y bindscrolltolower="nextPage"> <view > <block wx:for="{{lists}}" wx:for-index="index" wx:for-item="item" wx:key="unique"> <view > {{item}} </view> </block> </view> </scroll-view>
wxss:
.scroll_view{ height:100vh; }
js:
Page({ data: { lists: [], page: 1 }, //監(jiān)聽是否滑到底部 nextPage: function () { let new_lists = []; let page = this.data.page; let startindex = page * 10 + 1; console.log("第" + page + "頁滑到底部了,請求第" + (page + 1) + "頁"); page += 1; //模擬請求 for (let i = startindex; i <= startindex + 9; i++) { new_lists.push(i); } this.setData({ lists: this.data.lists.concat(new_lists), page: page }); }, onLoad: function (options) { let lists = []; //模擬請求 for (let i = this.data.page; i <= this.data.page + 9; i++) { lists.push(i) } this.setData({ lists: lists, }); }, })
關(guān)于怎么在微信小程序中實(shí)現(xiàn)一個(gè)下滑到底部自動翻頁功能就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。