ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
>[danger] 表格重载基础使用 ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>表格重载示例</title> <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css"> <script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script> </head> <body> <div class="layui-container" style="width:80%;padding-top:50px;"> <div class="layui-row"> <button class="reload1 layui-btn">通过容器ID重载</button> <button class="reload2 layui-btn">通过对象重载</button> <table id="demo" lay-filter="test"></table> </div> </div> </body> <script> layui.use(['table', 'layer'], function(){ var table = layui.table, $ = layui.jquery; //第一个实例 var tableIns = table.render({ elem: '#demo' ,url: 'table.json' //数据接口 ,page: true //开启分页 ,cols: [[ //表头 {field: 'id', title: 'ID', sort: true, fixed: 'left'} ,{field: 'username', title: '用户名'} ,{field: 'sex', title: '性别', sort: true} ,{field: 'city', title: '城市'} ,{field: 'sign', title: '签名'} ,{field: 'experience', title: '积分', sort: true} ,{field: 'score', title: '评分', sort: true} ]] }); // 表格重载 $('.reload1').click(function(){ // 特别注意 // 这里的参数是容器ID,不是lay-filter的值 table.reload('demo'); }) // 表格重载 $('.reload2').click(function(){ // tableIns 是 table.render() 返回的对象 tableIns.reload() }) }); </script> </html> ```