layui.use(['laypage', 'layer'], function(){
var laypage = layui.laypage
,layer = layui.layer;
var $ = layui.$;
var total_page = $("#total_page").val();
laypage.render({
elem: 'demo1'
,limit:1
,count: total_page
,curr: function(){ //通過url獲取當(dāng)前頁,也可以同上(pages)方式獲取
var page = location.search.match(/page=(\d+)/);
return page ? page[1] : 1;
}()
,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
,jump: function(obj, first){
//obj包含了當(dāng)前分頁的所有參數(shù),比如:
console.log(obj.curr); //得到當(dāng)前頁,以便向服務(wù)端請求對應(yīng)頁的數(shù)據(jù)。
console.log(obj.limit); //得到每頁顯示的條數(shù)
//首次不執(zhí)行
if(!first){
window.location.href="?page="+obj.curr;
}
}
});
});
當(dāng)前名稱:laypage分頁源碼
文章網(wǎng)址:
http://weahome.cn/article/pogesi.html