Layui is a domestic front-end UI framework written using its own module specifications, following the writing and organizational form of native HTML/CSS/JS. The threshold is extremely low and you can use it right out of the box. Built-in UI framework with some common elements and components.
The download address is http://www.layui.com/, and you can import it into the project after downloading.
<link> <script></script>
2. Introduction to LayPage parameters
aypage is a built-in encapsulated object that can be called directly when paging. There are mainly the following parameters here for Configure the key-value pair set of the layout page:
Key |
Default value |
Type |
Description |
##cont |
Required |
String/Object |
##Container. The value can be passed in element id or native DOM or jquery object
|
##Number of pages | |||
##1 |
Number |
Current page. |
##groups |
##5 |
Number |
The number of consecutive pages. |
##skin |
| String
|
##first
|
|
Number/String/ Boolean |
is used to control the home page. first: false, it means not to display the homepage items |
last
| |
Number/String/Boolean |
is used for control last page. last: false, it means that the last page item is not displayed |
prev
|
|
##String/Boolean |
is used for control One page. If it is not displayed, set false |
||
String/Boolean |
用于控制下一页。若不显示,设置false即可 |
||
jump |
核心参数 |
Function |
触发分页后的回调,函数返回两个参数。 |
<script> var pcountString= "${pcount}"; var psizeString= "${psize}"; var pcountInt= parseInt(pcountString);//总页数 var psizeInt=parseInt(psizeString); //页面大小 var pindex = "${pindex}";// 当前页 var ptotalpages=Math.ceil(pcountInt/psizeInt);// 总记录数 layui.define(['layer', 'laypage' ], function(exports) { var layer = layui.layer; var laypage = layui.laypage; var pcount = pcountInt;// 总记录数 var psize = psizeInt;// 每一页的记录数 // 分页 laypage({ cont : 'pagination', // 页面上的id pages : ptotalpages,//总页数 curr : pindex,//当前页 skin: '#999999',//颜色 jump : function(obj, first) { if (!first) { var parId=$("#parId").val(); var pindex=obj.curr; window.location.href="${ctx}/web/rest/RecycleManage/GetFileList?parId="+parId+"&pindex="+pindex;//跳转链接 } } }); });</script>
分页效果如下:
更多layui知识请关注PHP中文网layui教程栏目
The above is the detailed content of Use LayUI to implement front-end paging function. For more information, please follow other related articles on the PHP Chinese website!