npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

my-pagination-component

v1.0.2

Published

基于 Ant Design 的分页组件

Readme

📌 MyPagination 组件使用文档 📖 组件介绍 MyPagination 是一个基于 Ant Design 的分页组件,支持:

自定义分页大小(pageSizeOptions) 显示总条数(showTotal) 分页变更回调(onChange) 自定义样式(style) 该组件封装了 antd 的 Pagination 组件,使分页功能更直观,适用于表格、列表等数据展示场景。

🚀 安装

  1. 直接安装 npm 包
npm install my-pagination-component

或者使用 yarn:

yarn add my-pagination-component
  1. 安装 antd 依赖
npm install antd

🛠 组件使用 📌 基本用法

import React, { useState } from 'react';
import { MyPagination } from 'my-pagination-component';

const Demo = () => {
  const [current, setCurrent] = useState(1);
  const [pageSize, setPageSize] = useState(20);

  const handlePageChange = (page: number, size: number) => {
    setCurrent(page);
    setPageSize(size);
  };

  return (
    <MyPagination
      current={current}
      pageSize={pageSize}
      total={500} // 数据总数
      onChange={handlePageChange}
      pageSizeOptions={[10, 20, 50]} // 可选分页大小
    />
  );
};

export default Demo;

🔧 API 📌 组件参数

属性 | 说明 | 类型 | 默认值 ---|---|---|--- current | 当前页码 | number | 1 pageSize | 每页条数 | number | 20 total | 数据总条数 | number | 0 onChange | 页码或 pageSize 变化回调 | (page: number, pageSize: number) => void | - pageSizeOptions | 可选分页大小选项 | number[] | [20, 50, 100] style | 自定义 CSS 样式 | React.CSSProperties | {}

📌 进阶用法 1️⃣ 配合表格使用 通常在 Table 组件中,分页与数据展示结合使用:

import React, { useState } from 'react';
import { Table } from 'antd';
import { MyPagination } from 'my-pagination-component';

const Demo = () => {
  const [data, setData] = useState(
    Array.from({ length: 100 }).map((_, i) => ({ key: i, name: `用户${i + 1}` }))
  );
  const [current, setCurrent] = useState(1);
  const [pageSize, setPageSize] = useState(10);

  const handlePageChange = (page: number, size: number) => {
    setCurrent(page);
    setPageSize(size);
  };

  return (
    <div>
      <Table
        columns={[{ title: '姓名', dataIndex: 'name' }]}
        dataSource={data.slice((current - 1) * pageSize, current * pageSize)}
        pagination={false}
      />
      <MyPagination
        current={current}
        pageSize={pageSize}
        total={data.length}
        onChange={handlePageChange}
      />
    </div>
  );
};

export default Demo;

2️⃣ 自定义分页样式 可以使用 style 传入自定义样式:


<MyPagination
 current={1}
 pageSize={20}
 total={200}
 onChange={(page, size) => console.log(page, size)}
 style={{ marginTop: '30px', background: '#f5f5f5', padding: '10px', borderRadius: '5px' }}
/>

🛠 注意事项 total 需要传入数据总条数,否则分页不会生效。 pageSizeOptions 需要是 number[],否则可能导致 antd 组件异常。 onChange 需要传递处理函数,否则分页变化不会生效。