目录  react基于antd二次封装分页组件Pagination     
 
react基于antd二次封装分页组件Pagination  
组件PaginationCom  
import  {  Pagination }  from  'antd' ; 
import  propTypes from  "prop-types" ; 
import  React from  'react' ; const  PaginationCom  =  ( props )  =>  { return  ( < div className= 'content'  style= { { marginTop :  '20px' } } > < Paginationtotal= { props. total} showSizeChanger= { props. showSizeChanger} showQuickJumper= { props. showQuickJumper} pageSizeOptions= { props. pageSizeOptions} current= { props. current} pageSize= { props. pageSize} showTotal= { ( total )  =>  ` 共  ${ total}  条 ` } onChange= { props. onChange} onShowSizeChange= { props. onShowSizeChange} / > < / div> ) 
} 
PaginationCom. propTypes =  { current :  propTypes. number. isRequired,  pageSize :  propTypes. number. isRequired, total :  propTypes. number. isRequired, onChange :  propTypes. func. isRequired,  onShowSizeChange :  propTypes. func. isRequired,  showSizeChanger :  propTypes. bool,  showQuickJumper :  propTypes. bool,  pageSizeOptions :  propTypes. array, size :  propTypes. string, 
} ; 
PaginationCom. defaultProps =  { current :  1 ,  pageSize :  10 ,  total :  0 ,  showSizeChanger :  true ,  showQuickJumper :  true ,  pageSizeOptions :  [ 10 , 20 , 50 ] , 
} ; 
export  default  PaginationComimport  React,  {  useState }  from  'react' ; 
import  PaginationCom from  "./PaginationCom" ; 
export  default  function  App ( props )  { const  [ page, setPage]  =  useState ( 1 ) const  [ pageSize, setPageSize]  =  useState ( 10 ) const  pageChange  =  ( page )  =>  { console. log ( 'pageChange' ,  page) ; setPage ( page) } const  pageSizeChange  =  ( page,  pageSize )  =>  { setPageSize ( pageSize) } return  ( < div className= 'content' > page -  { page} < PaginationCom  total= { 35 }  current= { page}  pageSize= { pageSize}  onChange= { pageChange}  onShowSizeChange= { pageSizeChange} > < / PaginationCom> < / div> ) 
}