Update main.js

This commit is contained in:
北海一刀 2021-11-18 09:45:51 +08:00
parent d76f7c8eca
commit c6880530ef
1 changed files with 10 additions and 4 deletions

View File

@ -81,12 +81,16 @@ import _ from "lodash";
this.props.onNextClick(page_num); this.props.onNextClick(page_num);
} }
onPageClick(e){ onPageClick(e){
console.log(e)
if(e=="…")
{
return;
}
this.setState({page:e}) this.setState({page:e})
this.props.onJumpPage(e) this.props.onJumpPage(e)
} }
onInputChange(e,page_num){ onInputChange(e,page_num){
console.log("当前页码变化")
let jump = e.target.value > page_num ? page_num : e.target.value; let jump = e.target.value > page_num ? page_num : e.target.value;
this.setState({jump_page:jump}) this.setState({jump_page:jump})
@ -139,6 +143,8 @@ import _ from "lodash";
btnPages.push(o); btnPages.push(o);
} }
let btns = this.getPageArr(btnPages,this.state.page,5)
return ( return (
<div className="pagination"> <div className="pagination">
<div className="pagination-context"> <div className="pagination-context">
@ -166,9 +172,9 @@ import _ from "lodash";
<div className="page-btn-group"> <div className="page-btn-group">
<Icon onClick={()=>{this.onPrevClick()}} type={"left"} className={ this.state.page > 1 ? "page-prev" :"page-prev disabled" } /> <Icon onClick={()=>{this.onPrevClick()}} type={"left"} className={ this.state.page > 1 ? "page-prev" :"page-prev disabled" } />
{ {
btnPages.map((item, index) => { btns.map((item, index) => {
return ( return (
<div onClick={()=>{this.onPageClick(item.page)}} key={index} className={ item.page == this.state.page ? "btn-page active":"btn-page"}>{item.text}</div> <div onClick={()=>{this.onPageClick(item)}} key={index} className={ item== this.state.page ? "btn-page active":"btn-page"}>{item}</div>
) )
}) })
} }