nodejs -数据分页ejs-分页控件

懒得封装, 没有思路的将就看看吧

 引用js 、css

1    <link href="http://cdn.staticfile.org/twitter-bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
2     <script src="http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js" type="text/javascript">script>
3     <script src="http://cdn.staticfile.org/twitter-bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript">script> 

 

 
   

<ul class="pagination pagination-centered"> <% var prevNum = 10; var nextNum=10; %> <%if(pager.pageCount-pager.pageCurrent > 5){%> <% prevNum = 5 %> <%} else {%> <%prevNum = prevNum - (pager.pageCount-pager.pageCurrent)%> <%}%> <%if(pager.pageCurrent-5 > 0){%> <% nextNum = 5 %> <%} else {%> <%nextNum = nextNum - (pager.pageCurrent) %> <%}%> <% if(pager.pageCount-pager.pageCurrent > 5 &&pager.pageCurrent-5 > 0 ){%> <% prevNum=5%> <% nextNum=4%> <%}%> <li class="disabled"><a href="javascript:void(0)"><%=pager.maxNum%>a>li> <li class="disabled"><a href="javascript:void(0)"><%=pager.pageCount%>a>li> <%if(pager.maxNum==0){%> <li class="disabled"><a href="javascript:void(0)">首页a>li> <%}else{%> <li><a href="<%=pager.pagePath%>current=1">首页a>li> <%}%> <%if(pager.pageCurrent==1){%> <li class="disabled"><a href="javascript:void(0)">上一页a>li> <%}else{%> <%if(pager.maxNum==0){%> <li class="disabled"><a href="javascript:void(0)">上一页a>li> <%}else{%> <li><a href="<%=pager.pagePath%>current=<%=parseInt(pager.pageCurrent)-1%>">上一页a>li> <%}%> <%}%> <% for(var i = prevNum; i > 0; i--){ %> <% if( parseInt(pager.pageCurrent)-i > 0 ) { %> <li><a href="<%=pager.pagePath%>current=<%=parseInt(pager.pageCurrent)-i%>"><%=(parseInt(pager.pageCurrent)-i)%>a>li> <%}}%> <li class="active"><a href="<%=pager.pagePath%>current=<%=pager.pageCurrent%>" ><%=pager.pageCurrent%>a>li> <% for(var i = 1; i <=nextNum; i++){ %> <% if( parseInt(pager.pageCurrent)+i <= pager.pageCount ) { %> <li><a href="<%=pager.pagePath%>current=<%=parseInt(pager.pageCurrent)+i%>"><%=parseInt(pager.pageCurrent)+i%>a>li> <%}}%> <%if(pager.pageCurrent==pager.pageCount){%> <li class="disabled"><a href="javascript:void(0)">下一页a>li> <%}else{%> <%if(pager.maxNum==0){%> <li class="disabled"><a href="javascript:void(0)">下一页a>li> <%}else{%> <li><a href="<%=pager.pagePath%>current=<%=parseInt(pager.pageCurrent)+1%>">下一页a>li> <%}%> <%}%> <%if(pager.maxNum==0){%> <li class="disabled"><a href="javascript:void(0)">尾页a>li> <%}else{%> <li><a href="<%=pager.pagePath%>current=<%=pager.pageCount%>">尾页a>li> <%}%> ul>

 

转载于:https://www.cnblogs.com/abc101/p/5252880.html

你可能感兴趣的:(nodejs -数据分页ejs-分页控件)