在网页前台实现分页是经常要用的,有很多分页插件比如pagenation等,这里使用layui 分页,个人比较懒不喜欢手写,手写其实也差不多;话不多说,go。详细文档可以查看官方的:https://www.layui.com/demo/laypage.html
一、引入js、css
//js 需要放到jquery.js的下方
<script src="/js/layui.js" charset="utf-8"></script>
//css
<link href="/css/layui.css" rel="stylesheet">
二、前端html
<div class="text-center" id="page-wrapper"></div>
三、前端js部分
<script type="text/javascript">
var limit=10;//显示条数
var curr=1;//当前页数
var total=0;//数据条数
$(function(){
bindList(0,type);
});
//
function bindList(offset,type) {
$
.ajax({