Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/givebest/gb-pagination
Node.js 服务端渲染(SSR)分页。Node.js server-side rendering (SSR) pagination.
https://github.com/givebest/gb-pagination
ejs expressjs nodejs pagination
Last synced: 1 day ago
JSON representation
Node.js 服务端渲染(SSR)分页。Node.js server-side rendering (SSR) pagination.
- Host: GitHub
- URL: https://github.com/givebest/gb-pagination
- Owner: givebest
- License: mit
- Created: 2020-01-15T06:56:33.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T11:28:14.000Z (almost 5 years ago)
- Last Synced: 2024-10-17T18:55:14.479Z (19 days ago)
- Topics: ejs, expressjs, nodejs, pagination
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GB-Pagination
----## 简介
Node.js 服务端渲染(SSR)分页。
## 使用
### 普通分页
```js
// 引入
const gbPagination = require('gb-pagination.js')// 配置
gbPagination.init({
total: 101, // 总记录数
curPage: 1, // 当前页
size: 5 // 每页显示数量
})// 分页渲染
console.log(gbPagination.build())
```### Express.js + EJS 模板 中使用
#### JS
```js
var express = require('express');
var router = express.Router();const gbPagination = require('gb-pagination.js')
router.get('/:p', function(req, res, next) {
const curPage = req.params.p || 1
gbPagination.init({
total: 101,
curPage,
size: 5,
})res.render('index', { title: 'Express', pagination: gbPagination.build()});
});
```#### EJS
```html
<%- pagination %>
```## 选项
- `total`: 总记录数
- `curPage`: 当前页码
- `size`: 每页记录数 || 10
- `prevText`: 上一页文案 || '上一页',值为 false 不显示
- `nextText`: '下一页文案 || '下一页' 值为 false 不显示
- `pageInfo`: 分页信息,{{currentPage}}当前页码,{{totalPages}}总页数 || 当前第{{currentPage}}页/共{{totalPages}}页,值为 false 不显示## 感谢
> 本项目代码由 `GB-paging` 改进而来。
### GB-paging
> 兼容IE6+及现代浏览器的简单分页,支持同一页面多个分页。[https://github.com/givebest/GB-paging](https://github.com/givebest/GB-paging)
## License
[MIT](./LICENSE) © 2020 [givebest](https://github.com/givebest)