layui 在tab页签里多个table 分页不显示的解决方法

方式一:

1、检查后台代码返回的数据 count 里有没有设置,在table.render 的done 回调函数里打印信息,没有在后台设置即可.

done: function(res, curr, count){
  //如果是异步请求数据方式,res即为你接口返回的信息。
  //如果是直接赋值的方式,res即为:{data: [], count: 99} data为当前页数据、count为数据总长度
    console.log(res);
    //得到当前页码
    // console.log(curr); 
    //得到数据总量
    console.log("count---"+count);
		
}

方式二:手动渲染一下分页:

1、table后面定义一个分页的div,直接用table 的分页会显示在列表上面。

2、在done 函数里 手动渲染一个分页,引入 layerpage,

 

done: function(res, curr, count){

    //得到数据总量
    console.log("count---"+count);
    //执行一个laypage实例,完整功能
    laypage.render({
      elem: 'pager_com' //注意,这里的 div的 ID,不用加 # 号
      ,count: count //数据总数,从服务端得到
      ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
      ,jump: function(obj){
	 console.log(obj)
       }
    });
    form.render();
  }

 具体的分页样式,可根据自己的需要参考官网设置https://www.layui.com/demo/laypage.html


版权声明:本文为qianyel原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。