layui滚动分页

可以百度参考layui流加载。

首先,分页必须传的参数就是页码,以及每页几条数据

以下是我个人的代码:

$(function () {
   
    scrollPage();//监听滚动分页
});


function scrollPage() {
   
        var pageNum = 1;
        var pageSize = 3;
        var questionId = $("#questionId").val();
        $('#scroll-div').scroll(function(){
    //给需要滚动的区域设定要给div,然后触发滚动
            var scrollTop = $('#scroll-div').scrollTop();
            var viewportHeight = $('#scroll-div').height();
            var scrollHeight = $('#scroll-div')[0].scrollHeight;
            if (Math.round(scrollTop + viewportHeight) >= scrollHeight+17) {
   
                pageNum++;
                $.ajax({
   
                    type: "post",
                    url: "/jph/answer/scrollAnswer",
                    data: {
   "questionId": questionId, "pageNum": pageNum, "pageSize": pageSize},
                    success: function (obj) {
   
                        var html = "";
                        for 

你可能感兴趣的:(layui滚动分页)