Code Monkey home page Code Monkey logo

js-pagination's Introduction

# Pagination 
由原生 JavaScript 实现的页面分页器,不依赖任何第三方库。

- 包含编译后的 TypeScript 版本。
- 包含编译后的 Scss 样式文件。



## 使用

```javascript
const pagination = new Pagination({
    element: '#pagination-container',
    type: 1,
    pageIndex: 1,
    pageSize: 10,
    pageCount: 9,
    total: 100,
    prevText: '上一页',
    nextText: '下一页',
    jumper: false,
    singlePageHide: true,
    disabled: false,
    currentChange: function(index) {
        console.log('当前页码:', index);
    }
});

参数

  • element (string): 容器的选择器,用于放置分页组件。
  • type (number): 样式类型。1:带背景颜色 2:不带背景颜色
  • pageIndex (number): 当前页码。
  • pageSize (number): 每页显示数量。
  • pageCount (number): 按钮数量。
  • total (number): 总条数。
  • prevText (string): 上一页按钮显示的文字。
  • nextText (string): 下一页按钮显示的文字。
  • jumper (boolean): 是否显示输入框跳转功能。
  • singlePageHide (boolean): 是否在单页时隐藏分页控件。
  • disabled (boolean): 是否禁用分页控件。
  • currentChange (function): 按钮事件回调,接收当前页码作为参数。

示例

<div id="pagination-container"></div>

js:
const pagination = new Pagination({
    element: '#pagination-container',
    type: 1,
    pageIndex: 1,
    pageSize: 10,
    pageCount: 9,
    total: 100,
    prevText: '上一页',
    nextText: '下一页',
    jumper: false,
    singlePageHide: true,
    disabled: false,
    currentChange: function(index) {
        console.log('当前页码:', index);
    }
});

事件

  • currentChange(index): 当前页码发生变化时触发的回调函数。

js-pagination's People

Contributors

yxplus1116 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.