若依框架前端分页代码
若依框架前端分页代码
jquery实现前端代码
currentPage是当前页后端接收过来的;
totalPage是总页码数后端接收过来的
var lis="";
var begin;
var li;
var end;
var status;
alPage<8){
begin=1;
alPage;
status=“big”;
}else{
if((data.currentPage-1)<4&&(data.currentPage-1)>=0){
begin=1;
end=1+4;
status=“zbig”;
} else if((alPage-data.currentPage)<4){
alPage-4;
alPage;
status=“fbig”;
}else{
begin=data.currentPage-1;
end=data.currentPage+1;
status=“small”;
}
}
var beforeNum=data.currentPage-1;
if(beforeNum<1){
alPage;
}
var afterNum=data.currentPage+1;
if(afterNum&alPage){
afterNum=1;
}
if(status=="big"){
var before='<li class="page-pre" ><a href="javascript:void(0)" onclick="find('+beforeNum+','+data.pageSize+')">‹</a></li>'
lis+=before;
for (var i = begin; i <=end ; i++) {
if(i==data.currentPage){
li='<li class="page-number active" ><a href="javascript:void(0)" onclick="find('+i+','+data.pageSize+')">'+i+'</a ></li>';
}else {
li='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+i+','+data.pageSize+')">'+i+'</a></li>';
}
lis+=li;
}
var after='<li class="page-next"><a href="javascript:void(0)" onclick="find('+afterNum+','+data.pageSize+')" >›</a></li>'
lis+=after
jquery框架原理
}
if(status=="small"){
var before='<li class="page-pre" ><a href="javascript:void(0)" onclick="find('+beforeNum+','+data.pag
eSize+')">‹</a></li>'
lis+=before;
lis+=before;
var first='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+1+','+data.pageSize+')">'+1+'</a></li>'
lis+=first;
var dian='<li class="page-pre" ><a href="javascript:void(0)" onclick="find('+beforeNum+','+data.pageSize+')">..</a></li>'
lis+=dian;
for (var i = begin; i <=end ; i++) {
if(i==data.currentPage){
li='<li class="page-number active" ><a href="javascript:void(0)" onclick
="find('+i+','+data.pageSize+')">'+i+'</a ></li>';
}else {
li='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+i+','+data.pageSize+')">'+i+'</a></li>';
}
lis+=li;
}
lis+=dian;
var last='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+alPage+','+data.pageSize+')">'+alPage+'</a></li>'
lis+=last
var after='<li class="page-next"><a href="javascript:void(0)" onclick="find('+afterNum+','+data.pageSi
ze+')" >›</a></li>'
lis+=after
}
if(status=="fbig"){
var before='<li class="page-pre" ><a href="javascript:void(0)" onclick="find('+beforeNum+','+data.pageSize+')">‹</a></li>'
lis+=before;
var first='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+1+','+data.pageSize+')">'+1+'</a></li>'
lis+=first;
var dian='<li class="page-pre" ><a href="javascript:void(0)" onclick="find('+beforeNum+','+data.pageSize+')">..</a></li>'
lis+=dian;
for (var i = begin; i <=end ; i++) {
if(i==data.currentPage){
li='<li class="page-number active" ><a href="javascript:void(0)" onclick="find('+i+','+data.pageSize+')">'+i+'</a ></li>';
}else {
li='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+i+','+data.pageSize+')">'+i+'</a></li>';
}
lis+=li;
}
var after='<li class="page-next"><a href="javascript:void(0)" onclick="find('+afterNum+','+data.pageSi
ze+')" >›</a></li>'
lis+=after
}
if(status=="zbig"){
var before='<li class="page-pre" ><a href="javascript:void(0)" onclick="find('+beforeNum+','+data.pageSize+')">‹</a></li>'
lis+=before;
for (var i = begin; i <=end ; i++) {
if(i==data.currentPage){
li='<li class="page-number active" ><a href="javascript:void(0)" onclick="find('+i+','+data.pageSize+')">'+i+'</a ></li>';
}else {
li='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+i+','+data.pageSize+')">'+i+'</a></li>';
}
lis+=li;
}
var dian='<li class="page-pre" ><a href="javascript:void(0)" onclick="find('+beforeNum+','+data.pageSize+')">..</a></li>'
lis+=dian;
var last='<li class="page-pre"><a href="javascript:void(0)" onclick="find('+alPage+','+data.pageSize+')">'+alPage+'</a></li>'
lis+=last;
var after='<li class="page-next"><a href="javascript:void(0)" onclick="find('+afterNum+','+data.pageSize+')" >›</a></li>'
lis+=after
}
$("#pagenum").html(lis)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。