(●'◡'●)ノ
 
收藏文章 楼主

微信小程序上拉加载更多

版块:经验教程   类型:普通   作者:小狼人   查看:1881   回复:0   获赞:2   时间:2020-09-19 14:22:44
wxml

<scroll-view
		  	  style="height: 100%;"
		  	  scroll-y
		  	  bindscroll="scroll"
		  	  bindscrolltolower="reactBottom"
		  	  scroll-with-animation> 
需要渲染的内容
</scroll-view>
js


data //加载更多

      isLastPage: false,
      tips: '点击加载更多',
	  page:1,//当前页数
	  limit:18, //每页显示数量

请求getList() {

	 // 发起请求
	         wx.showLoading({
	             title: '加载中',
	         })
 	let that = this;
 	wx.request({
 		url: "",
		success: (res) => {
		       if (res.statusCode!= 200 || res.data.Code != 200) {
		           that.showError()
		       } else {
		           wx.hideLoading()
		           var newData = {}
		           if (res.data.Data.length < that.data.limit) {
		               // 没有数据了,已经是最后一页
		               newData.isLastPage = true;
		               newData.tips = "没有更多了";
		           }
		           // 追加数据
		           newData.navList = this.data.navList.concat(res.data.Data)
		           this.setData(newData)
		       }
		   },
		   fail: () => {
		       that.showError()
		   },
 	})
 },

  showError: function () {
      wx.showToast({
          title: "网络异常",
          icon: 'loading'
      })
  },

  reactBottom () {
    console.log('触底-加载更多');
	  if (this.data.isLastPage) {
	             return
	         }
	         this.setData({ 
	  				page: this.data.page + 1 ,
	  				})
	   this.getList();//请求
  },
    


赢得客户的认可,需要服务细节化 
回复列表
默认   热门   正序   倒序

回复:微信小程序上拉加载更多

Powered by HadSky 8.5.2

©2015 - 2025 爱宅域

加入官群 QQ咨询 友链展示 申请友链

您的IP:216.73.216.254,2025-06-14 10:53:07,Processed in 0.25359 second(s).

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息
已有0次打赏
(2) 分享
分享

请保存二维码或复制链接进行分享

取消