2.0.3 • Published 3 years ago

think-pagination-s v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

think-pagination-s

pagination for ThinkJS 3, if you want to use in ThinkJS 2.x, please view README_v2

install

npm install think-pagination-s

how to use

controller

const pagination = require('think-pagination-s');

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

{%-pagination%}

nunjucks

{{pagination | safe}}

API

pagination(pagerData, ctx, options)

  • pagerData get from by model.countSelect
  • ctx ctx object
  • options options

options:

{
  desc: false, //show description
  pageNum: 2, 
  url: '', //page url, when not set, it will auto generated
  ul_class: '', //pagenation extra ul class
  li_class: '', //pagenation extra li class
  a_class: '', //pagenation extra a class
  text: {
    next: 'Next',
    prev: 'Prev',
    total: 'count: __COUNT__ , pages: __PAGE__'
  }
}
2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago