react:封装组件

封装

/components/Pagination.tsx
import React from 'react'
import { Pagination } from 'antd'

const PaginationWarp = ({ total, paramsInfo, setParamsInfo }) => {
  return (
    <Pagination
      total={total}
      current={paramsInfo.page}
      showSizeChanger
      showQuickJumper
      defaultPageSize={100}
      onChange={(page, pageSize) => {
        const obj = {
          ...paramsInfo,
          page,
          pageSize,
        }
        setParamsInfo(obj)
      }}
      pageSizeOptions={['100', '50', '20']}
      showTotal={total => `总数 ${total}`}
    />
  )
}
export default PaginationWarp

使用

import PaginationWarp from '@/components/Pagination.tsx'
{total.current && (
          <PaginationWarp
            total={total.current}
            paramsInfo={paramsInfo}
            setParamsInfo={setparamsInfo}
          />
        )}

你可能感兴趣的:(react,react.js,javascript,前端)