@aboutbits/pagination 中文文档教程

发布于 3年前 浏览 21 项目主页 更新于 3年前

Pagination

 npm version

这个 pagacke 包含一个分页计算,您可以在其中简单地将一些基本信息传递给计算函数,作为回报,您会收到一个包含所有相关分页信息的对象。

Table of content

Usage

首先,您必须安装包:

npm install @aboutbits/pagination

其次,您可以通过传递以下信息来调用计算函数:

  • page: The current page
  • size: The amount of items shown per page
  • total: The amount of total items in the list/collection
  • config: A configuration object containing the following possible configuration values:
  • indexType: The starting point of the pagination (default: IndexType.ONE_BASED)
  • maxPages: The maximum amount of pages that should be shown (default: 5)

作为回报,您会收到一个包含所有相关信息的对象:

import { calculatePagination } from '@aboutbits/pagination'

let pagination = calculatePagination(1, 5, 100)

console.log(pagination)

这将返回以下对象:

{
  "previous": {
    "indexNumber": 1,
    "isDisabled": true
  },
  "next": {
    "indexNumber": 2,
    "isDisabled": false
  },
  "pages": [
    {
      "indexNumber": 1,
      "displayNumber": 1,
      "isCurrent": true
    },
    {
      "indexNumber": 2,
      "displayNumber": 2,
      "isCurrent": false
    },
    {
      "indexNumber": 3,
      "displayNumber": 3,
      "isCurrent": false
    },
    {
      "indexNumber": 4,
      "displayNumber": 4,
      "isCurrent": false
    },
    {
      "indexNumber": 5,
      "displayNumber": 5,
      "isCurrent": false
    }
  ]
}

Build & Publish

要构建和发布包,只需提交所有更改并将它们推送到 master。 然后在本地运行以下命令之一:

npm version patch
npm version minor
npm version major

Information

About Bits 是一家位于意大利南蒂罗尔的公司。 您可以在我们的网站上找到更多关于我们的信息。

Support

如需支持,请联系 info@aboutbits.it

Credits

License

麻省理工学院许可证(麻省理工学院)。 请参阅许可文件了解更多信息。

Pagination

npm version

This pagacke includes a pagination calculation, where you can simply pass some basic information to the calcualtion function, and in return you receive an object with all relevant pagination information.

Table of content

Usage

First, you have to install the package:

npm install @aboutbits/pagination

Second, you can call the calculate function by passing the following information:

  • page: The current page
  • size: The amount of items shown per page
  • total: The amount of total items in the list/collection
  • config: A configuration object containing the following possible configuration values:
  • indexType: The starting point of the pagination (default: IndexType.ONE_BASED)
  • maxPages: The maximum amount of pages that should be shown (default: 5)

In return, you receive an object with all relevant information:

import { calculatePagination } from '@aboutbits/pagination'

let pagination = calculatePagination(1, 5, 100)

console.log(pagination)

This would return the following object:

{
  "previous": {
    "indexNumber": 1,
    "isDisabled": true
  },
  "next": {
    "indexNumber": 2,
    "isDisabled": false
  },
  "pages": [
    {
      "indexNumber": 1,
      "displayNumber": 1,
      "isCurrent": true
    },
    {
      "indexNumber": 2,
      "displayNumber": 2,
      "isCurrent": false
    },
    {
      "indexNumber": 3,
      "displayNumber": 3,
      "isCurrent": false
    },
    {
      "indexNumber": 4,
      "displayNumber": 4,
      "isCurrent": false
    },
    {
      "indexNumber": 5,
      "displayNumber": 5,
      "isCurrent": false
    }
  ]
}

Build & Publish

To build and publish the package, simply commit all changes and push them to master. Then run one of the following commands locally:

npm version patch
npm version minor
npm version major

Information

About Bits is a company based in South Tyrol, Italy. You can find more information about us on our website.

Support

For support, please contact info@aboutbits.it.

Credits

License

The MIT License (MIT). Please see the license file for more information.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文