日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

小程序上拉加载,下拉刷新

發布時間:2024/4/15 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 小程序上拉加载,下拉刷新 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

小程序上拉加載,下拉刷新

data: {collectinformation: null,number: 1,size: 10,isOpenLoading: true,isEmpty: true,isLoadingTrue: true,mylist: null,mylists: null,}, onPullDownRefresh部分代碼 //下拉刷新onPullDownRefresh: function(e) {this.setData({isEmpty: true,number: 1,mylist: [],isLoadingTrue: true})this.getList();}, onReachBuottom部分 isOpenLoading就是添加的閘門,目的是防止一個方法還沒有結束就發起另外一個請求,造成num的混亂 onReachBottom: function(e) {if (this.data.isOpenLoading) {this.getList()} else {return}}, getList()部分 call.myRequest這邊被我封裝了,可以直接用自己的 getList: function() {var that = thisthat.setData({mylists: [],isShowIcon: false,isOpenLoading: false})wx.showNavigationBarLoading()var myData = {category: 0,number: that.data.number,size: that.data.size}call.myRequest("/user/collections/", that.listSuc, "POST", myData)},listSuc: function(data, res) {var that = thisvar totalList = [];that.data.mylists = data.valueif (!that.data.mylists || !that.data.mylists.length) {that.setData({isLoadingTrue: false,isShowIcon: true,isOpenLoading: false});wx.hideNavigationBarLoading();wx.stopPullDownRefresh();return}if (!that.data.isEmpty) {totalList = that.data.mylist.concat(that.data.mylists);} else {totalList = that.data.myliststhat.data.isEmpty = false}that.setData({mylist: totalList,isLoadingTrue: true,isShowIcon: true,isOpenLoading: true})wx.hideNavigationBarLoading();wx.stopPullDownRefresh();that.data.number += 1},

onLoad部分

onLoad: function(options) {this.$wuxRater = app.Wux().$wuxRaterwx.setNavigationBarTitle({title: '我的收藏',})this.onPullDownRefresh()}, 有個不太友好的問題就是在刷新的時候我就清空了mylists中的數據,雖然加了loading,感覺還是不太好。尤其是在突然斷網的情況下,頁面上就剩下幾個loading,倍感凄涼。

轉載于:https://www.cnblogs.com/chengmingxiaowu/p/9847994.html

總結

以上是生活随笔為你收集整理的小程序上拉加载,下拉刷新的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。