添加分页组件

master
pan 5 years ago
parent 9974cbb7b3
commit 9846accf96
  1. 21
      src/Page.tsx
  2. 12
      src/entity.ts
  3. 24
      src/sub/IndexMenu.tsx

@ -0,0 +1,21 @@
import {PageForm} from "./entity";
import React from "react";
import {Pagination} from "react-bootstrap";
/**
*
*/
export class Page extends React.Component<PageForm, PageForm>{
render() {
return (
<Pagination className="justify-content-center">
{this.props.currentPage===1?<Pagination.First disabled/>:<Pagination.First/>}
{this.props.currentPage>1?<Pagination.Prev/>:<Pagination.Prev disabled/>}
<Pagination.Item active>{this.props.currentPage}</Pagination.Item>
{this.props.currentPage<this.props.totalPage?<Pagination.Next/>:<Pagination.Next disabled/>}
{this.props.currentPage===this.props.totalPage?<Pagination.Last disabled/>:<Pagination.Last/>}
</Pagination>
);
}
}

@ -11,3 +11,15 @@ export interface ActiveForm {
//活动图片 //活动图片
activeImg:string; activeImg:string;
} }
/**
*
*/
export interface PageForm {
//当前页
currentPage:number;
//总页数
totalPage:number;
//分页大小
pageSize:number;
}

@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import {Container,Row,Col,Card,ListGroup,Button,Pagination} from "react-bootstrap"; import {Container,Row,Col,Card,ListGroup,Button} from "react-bootstrap";
import {ActiveForm} from "../entity"; import {ActiveForm} from "../entity";
import {Page} from "../Page";
/** /**
* *
*/ */
@ -15,7 +16,8 @@ export class IndexMenu extends React.Component<any, any>{
activeList:[], activeList:[],
page:{ page:{
currentPage:1, currentPage:1,
totalPage:1 totalPage:3,
pageSize:9
} }
} }
} }
@ -106,26 +108,16 @@ export class IndexMenu extends React.Component<any, any>{
) )
return ( return (
<Container className="p-5"> <Container className="p-5">
<Pagination className="justify-content-center"> <Page currentPage={this.state.page.currentPage} totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/>
{this.state.page.currentPage===1?<Pagination.First disabled/>:<Pagination.First/>}
{this.state.page.currentPage-1>0?<Pagination.Prev/>:<Pagination.Prev disabled/>}
<Pagination.Item active>{this.state.page.currentPage}</Pagination.Item>
{this.state.page.currentPage+1<this.state.page.totalPage?<Pagination.Next/>:<Pagination.Next disabled/>}
{this.state.page.currentPage===this.state.page.totalPage?<Pagination.Last disabled/>:<Pagination.Last/>}
</Pagination>
<div> <div>
{rowList} {rowList}
</div> </div>
<Pagination className="justify-content-center"> <Page currentPage={this.state.page.currentPage} totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/>
{this.state.page.currentPage===1?<Pagination.First disabled/>:<Pagination.First/>}
{this.state.page.currentPage-1>0?<Pagination.Prev/>:<Pagination.Prev disabled/>}
<Pagination.Item active>{this.state.page.currentPage}</Pagination.Item>
{this.state.page.currentPage+1<this.state.page.totalPage?<Pagination.Next/>:<Pagination.Next disabled/>}
{this.state.page.currentPage===this.state.page.totalPage?<Pagination.Last disabled/>:<Pagination.Last/>}
</Pagination>
</Container> </Container>
) )
} }

Loading…
Cancel
Save