html52.com
我爱小程序-开发者交流社区

上拉加载数据会加载好几页,而且有重复

问题模块
API和组件

var page = 1;

var limit = 5;

var GetList = function (that) {

  that.setData({

    hidden: false

  });

  wx.request({

    url: url,

    data: {

      page: page,

      limit: limit,

    },

    method: 'POST',

    header: {

      'content-type': 'application/x-www-form-urlencoded'

    },

    success: function (res) {

      console.log("get:" + page)

      var list = that.data.list;

      for (var i = 0; i < res.data.length; i++) {

        list.push(res.data[i].fields);

      }

      that.setData({

        list: list,

      });

      page++;

      that.setData({

        hidden: true

      });

    }

  });

}

Page({

  data: {

    hidden: false,

    list: [],

    scrollHeight: 0,

    scrollTop:0

  },

  onLoad: function () {

    var that = this;

    wx.getSystemInfo({

      success: function (res) {

        console.info('heith' + res.windowHeight);

        that.setData({

          scrollHeight: res.windowHeight

        });

      }

    });

    GetList(that);

  },

  bindDownLoad: function () {

    //  该方法绑定了页面滑动到底部的事件

    var that = this;

    GetList(that);

  },


})



评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付