Layui Table组件,设置data数据源,以及page为False,表格只能显示10条数据的问题

代码如下:

javascript 复制代码
//显示表个数据
        table.render({
            elem: '#' + tableId
            , height: 350
            , page: false // 开启分页
            , skin: 'row' // 行边框风格
            , even: true // 开启隔行背景
            , defaultToolbar: ['filter']
            , toolbar: '#active' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
            , cols: [[
                {field: 'id', title: 'ID', hide: true},
                {field: 'warehouseName', title: '库位', align: 'center', minWidth: 150},
                {field: 'warehouseReleaseDate', title: '预约出仓日期', align: 'center', width: 300},
                {fixed: 'right', title: '操作', align: 'center', toolbar: '#action', width: 150}
            ]],
            data: tableData,
        });

测试中,发现tableData数据大于10条时,表格依然只展示10条数据。后面查layui文档,才发现即是设置page为false时,外面的limit参数依然生效。

解决方法

增加limit配置即可。

javascript 复制代码
 //显示表个数据
        table.render({
            elem: '#' + tableId
            , height: 350
            , page: false // 开启分页
            , skin: 'row' // 行边框风格
            , even: true // 开启隔行背景
            , defaultToolbar: ['filter']
            , toolbar: '#active' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
            , cols: [[
                {field: 'id', title: 'ID', hide: true},
                {field: 'warehouseName', title: '库位', align: 'center', minWidth: 150},
                {field: 'warehouseReleaseDate', title: '预约出仓日期', align: 'center', width: 300},
                {fixed: 'right', title: '操作', align: 'center', toolbar: '#action', width: 150}
            ]],
            data: tableData,
            limit: tableData.length
        });
相关推荐
Kevin Wang72732 分钟前
解除chrome中http无法录音问题,权限
前端·chrome
vipbic35 分钟前
使用Cursor开发Strapi5插件bag-strapi-plugin
前端·ai编程·cursor
专注前端30年38 分钟前
【JavaScript】reduce 方法的详解与实战
开发语言·前端·javascript
ikoala41 分钟前
Node.js 25 正式发布:性能飙升、安全升级、全面向 Web 靠拢!
前端·面试·node.js
陈振wx:zchen20081 小时前
前端-ES6-11
前端·es6
菜鸟una1 小时前
【瀑布流大全】分析原理及实现方式(微信小程序和网页都适用)
前端·css·vue.js·微信小程序·小程序·typescript
专注前端30年2 小时前
2025 最新 Vue2/Vue3 高频面试题(10月最新版)
前端·javascript·vue.js·面试
文火冰糖的硅基工坊2 小时前
[嵌入式系统-146]:五次工业革命对应的机器人形态的演进、主要功能的演进以及操作系统的演进
前端·网络·人工智能·嵌入式硬件·机器人
2401_837088503 小时前
ResponseEntity - Spring框架的“标准回复模板“
java·前端·spring
yaoganjili3 小时前
用 Tinymce 打造智能写作
前端