获取layui表格(table)当前页的页码值和当前页的数据条数
在浏览器查看源码,获取当前页面的数据条数如下

核心代码
| $(".layui-laypage-limits").find("option:selected").val() |
| $(".layui-laypage-skip").find("input").val() |
| |

下面是我项目中把加载数据封装到了一个方法里面
| var currNum = 1; |
| if (localStorage.getItem("layuiPageSize") == null) { |
| localStorage.setItem("layuiPageSize", 20); |
| } |
| function LoadData(currIndex) { |
| |
| table.render({ |
| elem: '#demo' |
| |
| , method: 'get' |
| , url: '../api/User/AlipayData2' |
| , request: { |
| pageName: 'PageIndex', |
| limitName: 'PageSize' |
| } |
| , title: '用户表' |
| , page: { |
| limit: localStorage.getItem("layuiPageSize") |
| , limits: [20, 30, 50, 100, 200, 300, 500, 1000] |
| , curr: currIndex |
| |
| |
| } |
| , where: { UserName: $("#UserName").val(), OrderId: $("#OrderId").val(), State: $("#State").val() } |
| , toolbar: 'default' |
| , totalRow: true |
| , cols: [[ |
| { type: 'checkbox', fixed: 'left' } |
| , { field: 'UserName', title: '用户名', width: 100 } |
| , { field: 'money', title: '金额', width: 80, sort: true, totalRow: true } |
| , { field: 'orderid', title: '订单号', width: 210, sort: true } |
| , { field: 'orderTime', title: '创建时间', width: 165 } |
| , { field: 'state', title: '状态', width: 80 } |
| , { field: 'subject', title: 'subject', width: 160 } |
| , { field: 'body', title: 'body' } |
| ]] |
| , done: function (obj, first) { |
| let pageSize = $(".layui-laypage-limits").find("option:selected").val(); |
| localStorage.setItem("layuiPageSize", pageSize); |
| currNum = first; |
| if (obj.msg == '无数据' && first > 1) { |
| currNum = first - 1; |
| LoadData(currNum); |
| } |
| $("[data-field='state']").children().each(function () { |
| |
| if ($(this).text() == '1') { |
| $(this).text('已支付'); |
| |
| } else if ($(this).text() == '0') { |
| $(this).text('未支付'); |
| } |
| else if ($(this).text() == '2') { |
| $(this).text('已结算'); |
| } |
| }); |
| } |
| }); |
| } |
| |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了