apicloud触底加载的简单实现

直接上干货

api.addEventListener({
            name: 'scrolltobottom',
            extra: {
                threshold: 0
            }
        }, function(ret, err) {
          index += 1;
          var data = {
              categoryId: 0,
              pageNum: index,
              pageSize: 10
          }
          ajaxRequest('/api/Shop/GoodsListFromCategory?', 'get', data, true, function(ret) {
              if (ret.code == 200) {
                if (ret.res.data.count == 0) {
                  toast("没有更多数据了!")
                }else {
                  main.list = main.list.concat(ret.res.data.list);
                }
              } else {
                  toast(ret.res.msg)
              }
          })
        });

猜你喜欢

转载自www.cnblogs.com/yechangzhong-826217795/p/10905390.html