添加分页组件

master
pan 4 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;
}
/**
*
*/
export interface PageForm {
//当前页
currentPage:number;
//总页数
totalPage:number;
//分页大小
pageSize:number;
}

@ -1,6 +1,7 @@
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 {Page} from "../Page";
/**
*
*/
@ -15,7 +16,8 @@ export class IndexMenu extends React.Component<any, any>{
activeList:[],
page:{
currentPage:1,
totalPage:1
totalPage:3,
pageSize:9
}
}
}
@ -106,26 +108,16 @@ export class IndexMenu extends React.Component<any, any>{
)
return (
<Container className="p-5">
<Pagination className="justify-content-center">
{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>
<Page currentPage={this.state.page.currentPage} totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/>
<div>
{rowList}
</div>
<Pagination className="justify-content-center">
{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>
<Page currentPage={this.state.page.currentPage} totalPage={this.state.page.totalPage} pageSize={this.state.page.pageSize}/>
</Container>
)
}

Loading…
Cancel
Save