Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including node-pagination with all npm packages installed. Try it out:

var nodePagination = require("node-pagination")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-pagination v1.0.1

pagination for Node.js

##Pagination Node.js Library 基于Node.js版的JavaScript分页组件

使用方法:

安装:

$ npm install -g node-pagination

使用:

var pagination = require("node-pagination");

total : 总数 page : 当前页 pagesize : 每页包含的内容 offset : 偏移量(例如1 2 3 4 5 6,点击6时,产生4 5 6 7 8 9,而非 7 8 9 10 11 12) length : 例如 上一页 2 3 4 5 6 下一页,则步长为5

pv = pagination.build( total, page, pagesize, offset, length );

计算后结果:

pv.total      //总数
pv.page       //当前页
pv.pagesize   //每页的内容数
pv.lastpage   //最后一页
pv.loopcount  //共计多少分页
pv.previous   //前一页
pv.next       //后一页
pv.isprevious //是否显示前一页
pv.isnext     //是否显示后一页
pv.begin      //开始
pv.end        //结束
pv.length     //原始的步长(即传入的参数,也是begin -> end时的步长)
pv.step       //步长(真实的步长)
pv.isforward  //是否可以前进,指">>"
pv.isback     //是否可以后退,指"<<"
pv.forward    //前进到第几页
pv.back       //后退到第几页
pv.offset     //偏移量

测试:

..\node_modules\node-pagination\test\node test.js

其他版本的分页组件:
JavaScript版:https://github.com/Kenshin/js-pagination

更新日志:

version 1.0.0 [2012-05-05]

  • 基于Node.js
  • 支持复杂分页

联系方式:

版权和许可:

Copyright 2012 k-zone.cn
Licensed under MIT or GPL Version 2 licenses

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free