1.0.0 • Published 6 years ago
bplokjs-pagination v1.0.0
bplokjs-pagination
生成pagination数据对象
安装
npm install --save bplokjs-pagination
构造函数
Pagination({
total: 100,
current: 1,
pageSize: 10,
pageRange: 5
})
属性
total
总数current
当前页 默认为1pageSize
页码大小 默认为10pageRange
分页按钮显示的最大数 默认为5
方法
getCurrentRange( fn )
获取当前分页的列表。该方法接收一个函数作为结果項进行处理
getPageTotal()
获取页面总数isFirstPage(pn)
判断是否第一页isLastPage(pn)
作用同上getNext()
获取下一页的页码,如果不存在则返回nullgetPrevious()
作用同上previous()
翻页,上一页,如果失败则返回falsenext()
翻页,下一页,如果失败则返回false
示例
const pagination = new Pagination({
total: 161,
pageSize: 10,
pageRange: 5
});
console.log( pagination.getCurrentRange() );
pagination.current = 8;
console.log( pagination.getCurrentRange() );
pagination.next();
console.log( pagination.getCurrentRange() );
//getCurrentRange() 返回示例
[ { page: 1, isCurrent: false },
{ page: null, isPreviousMore: true },
{ page: 7, isCurrent: false },
{ page: 8, isCurrent: false },
{ page: 9, isCurrent: true },
{ page: 10, isCurrent: false },
{ page: 11, isCurrent: false },
{ page: null, isNextMore: true },
{ page: 17, isCurrent: false } ]
1.0.0
6 years ago