Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uiw/react-pagination

Package Overview
Dependencies
Maintainers
2
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uiw/react-pagination

Pagination component

  • 5.0.0-bate-17
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
122
decreased by-32.22%
Maintainers
2
Weekly downloads
 
Created
Source

Pagination 分页

Open in unpkg NPM Downloads npm version

当数据量较多时,使用分页可以快速进行数据切换,每次只加载一个页面。

import { Pagination } from 'uiw';
// or
import Pagination from '@uiw/react-pagination';

基本用法

import React from 'react';
import { Pagination, Divider } from 'uiw';


const Demo = () => {
  const [pageObj, setPageObj] = React.useState({
    current: 2,
    pageSize: 10
  });
  return (
    <div>
      <Pagination
        current={pageObj.current}
        pageSize={pageObj.pageSize}
        total={30}
        divider
        pageSizeOptions={[5, 10, 20, 30]}
        onShowSizeChange={(current, pageSize) => setPageObj({
          current: current,
          pageSize: pageSize
        })}
      />
      <Divider />
      <Pagination current={2} pageSize={10} total={38} divider />
      <Divider />
      <Pagination current={1} pageSize={5} total={249} pageSizeOptions={[5, 10, 20, 30]} />
      <Divider />
      <Pagination current={1} alignment="center" pageSize={10} total={50} />
      <Divider />
      <Pagination current={1} pageSize={10} total={60} divider />
      <Divider />
      <Pagination current={1} pageSize={10} total={70} divider />
    </div>
  )
}

export default Demo

迷你分页

import React from 'react';
import { Pagination, Divider } from 'uiw';

function Demo() {
  return <div>
    <Pagination size="small" current={1} pageSize={5} pageSizeOptions={[5, 10, 20, 30]} total={249} />
    <Divider />
    <Pagination size="small" current={1} pageSize={10} total={50} />
  </div>
}
export default Demo

对齐

目前有三种对齐方式 左边(left)中间(center)右边(right)

import React from 'react';
import { Pagination, Divider } from 'uiw';

function Demo() {
  return <div>
    <Pagination
      current={5}
      total={250}
      onChange={(pageNumber) => { 
        console.log(`pageNumber:${pageNumber}`)
      }}
    />
    <Divider />
    <Pagination
      current={1}
      alignment="center"
      total={250}
      onChange={(pageNumber) => { 
        console.log(`pageNumber:${pageNumber}`)
      }}
    />
    <Divider />
    <Pagination
      current={25}
      alignment="right"
      total={250}
      onChange={(pageNumber) => { 
        console.log(`pageNumber:${pageNumber}`)
      }}
    />
  </div>
}

export default Demo

Props

参数说明类型默认值
current当前页数,选中的页数Number1
total数据总数Number0
pageSize每页条数Number10
pageSizeOptions指定每页可以显示多少条Number[]-
divider页码之间是否间隔Boolean-
size当为 small 时,是小尺寸分页Enum{small, default}-
alignment对齐Enum{left, center, right}left
onChange页码改变的回调,返回改变后的页码Function(current, total, pageSize)-
onShowSizeChangepageSize 变化的回调Function(current, pageSize)-

Keywords

FAQs

Package last updated on 09 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc