真的崩潰,怎么都實現不了分頁效果。獲取數據11條,設置顯示8條,它顯示11條。
后來看一個大佬的文章:https://blog.csdn.net/qq_38642674/article/details/105487465
自己做一個備忘。
layui.use('table', function(){ var table = layui.table; $.ajax({ type: "POST", url: "/adminInfoReal/getListAdminInfoReal", dataType: "json" ,success:function (datal) { if (datal){ var option={ elem: '#adminRealTable'//table的id ,height: 480 ,page:true ,limit:8 ,title: '用戶數據表' ,cols: [[ //表頭 {type: 'checkbox', fixed: 'left'}//開啟復選框 ,{field: 'adminRealUserId', title: '身份證號', width:100, sort: true, fixed: 'left'} ,{field: 'adminRealName', title: '姓名', width:100} ,{field: 'adminRealPhone', title: '手機號', width:100, sort: true} ,{field: 'adminRealEmail', title: '郵箱', width:100} ,{field: 'adminRealAddress', title: '城市', width: 6000} ,{ title:'操作', toolbar: '#barDemo',width:150, sort: true,fixed: 'right'} ]] }; option.data=datal.data; table.render(option); }else{ layer.msg("數據獲取失敗"); } } ,error:function (datal) { layer.msg("數據獲取失敗"); } }); });