Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thinkjs/think-pagination
Pagination for ThinkJS 3 & 2
https://github.com/thinkjs/think-pagination
pagination thinkjs
Last synced: about 1 month ago
JSON representation
Pagination for ThinkJS 3 & 2
- Host: GitHub
- URL: https://github.com/thinkjs/think-pagination
- Owner: thinkjs
- License: mit
- Created: 2016-01-11T02:05:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-06-30T23:36:23.000Z (over 3 years ago)
- Last Synced: 2024-05-11T12:44:21.054Z (7 months ago)
- Topics: pagination, thinkjs
- Language: JavaScript
- Homepage: https://thinkjs.org
- Size: 11.7 KB
- Stars: 13
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-pagination
README
# think-pagination
pagination for ThinkJS 3, if you want to use in ThinkJS 2.x, please view [README_v2](./README_v2.md)
## install
```sh
npm install think-pagination
```## how to use
### controller
```js
const pagination = require('think-pagination');module.exports = class extends think.Controller {
async indexAction() {
const data = await this.model('user').page(this.get('page')).countSelect();
const html = pagination(data, this.ctx, {});
this.assign('pagination', html);
}
}
```### view
#### ejs
```html
{%-pagination%}
```#### nunjucks
```html
{{pagination | safe}}
```## API
### pagination(pagerData, ctx, options)
* `pagerData` get from by model.countSelect
* `ctx` ctx object
* `options` options`options`:
```js
{
desc: false, //show description
pageNum: 2,
url: '', //page url, when not set, it will auto generated
class: '', //pagenation extra class
text: {
next: 'Next',
prev: 'Prev',
total: 'count: __COUNT__ , pages: __PAGE__'
}
}
```