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 = total, page, pagesize, offset, length );

计算后结果:      //总数       //当前页
pv.pagesize   //每页的内容数
pv.lastpage   //最后一页
pv.loopcount  //共计多少分页
pv.previous   //前一页       //后一页
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



version 1.0.0 [2012-05-05]

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



Copyright 2012
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