From cf64e757dcc3245e93008da93bd6e2f22d03ab81 Mon Sep 17 00:00:00 2001 From: jl-zhoujl2 Date: Fri, 1 Jul 2022 20:53:37 +0800 Subject: [PATCH] =?UTF-8?q?7.1=20=E6=B4=BB=E5=8A=A8=E9=A3=8E=E9=87=87?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=92=8C=E6=94=BB=E5=9D=9A=E5=85=8B=E9=9A=BE?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=B8=80=E9=A1=B5?= =?UTF-8?q?=E5=92=8C=E4=B8=8B=E4=B8=80=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PartyMemberTopic/ActivityStyle/index.tsx | 19 +++++++++++++++---- .../PartyMemberTopic/OverDifficult/index.tsx | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/pages/PartyMemberTopic/ActivityStyle/index.tsx b/src/pages/PartyMemberTopic/ActivityStyle/index.tsx index 9a42d98..44d42d8 100644 --- a/src/pages/PartyMemberTopic/ActivityStyle/index.tsx +++ b/src/pages/PartyMemberTopic/ActivityStyle/index.tsx @@ -14,6 +14,8 @@ const PersonInfor: React.FC<{}> = () => { const [gracefulList, setGracefulList] = useState([]); //loading const [loading, setLoading] = useState(false); + //page + const [page, setPage] = useState(1); //get graceful const getGracefulData = (value: string) => { @@ -36,9 +38,13 @@ const PersonInfor: React.FC<{}> = () => { const toHome = () => { history.push("/partyMemberTopic/home"); } - //goback lastpage - const toGoBack = () => { - window.history.go(-1); + //to previous page + const toPreviousPage = () => { + setPage((page) => page - 1); + } + //to next page + const toNextPage = () => { + setPage((page) => page + 1); } useEffect(() => { @@ -49,7 +55,8 @@ const PersonInfor: React.FC<{}> = () => {
toHome()}>返回首页 - toGoBack()}>上一页 + {page > 1 && toPreviousPage()}>上一页} + {gracefulList.length != 0 && page < Math.ceil(gracefulList.length / 10) && toNextPage()}>下一页}
@@ -70,6 +77,10 @@ const PersonInfor: React.FC<{}> = () => { itemLayout="horizontal" pagination={{ size: 'small', + onChange: page => { + setPage(page); + }, + current: page, showTotal: (total) => `共 ${total} 条`, pageSize: 10, }} diff --git a/src/pages/PartyMemberTopic/OverDifficult/index.tsx b/src/pages/PartyMemberTopic/OverDifficult/index.tsx index bc7f582..73ec67e 100644 --- a/src/pages/PartyMemberTopic/OverDifficult/index.tsx +++ b/src/pages/PartyMemberTopic/OverDifficult/index.tsx @@ -12,6 +12,8 @@ const PersonInfor: React.FC<{}> = () => { const [projectList, setProjectList] = useState([]); //loading const [loading, setLoading] = useState(false); + //page + const [page, setPage] = useState(1); //get project const getProjectData = (value: string) => { @@ -34,9 +36,13 @@ const PersonInfor: React.FC<{}> = () => { const toHome = () => { history.push("/partyMemberTopic/home"); } - //goback lastpage - const toGoBack = () => { - window.history.go(-1); + //to previous page + const toPreviousPage = () => { + setPage((page) => page - 1); + } + //to next page + const toNextPage = () => { + setPage((page) => page + 1); } useEffect(() => { @@ -48,7 +54,8 @@ const PersonInfor: React.FC<{}> = () => {
toHome()}>返回首页 - toGoBack()}>上一页 + {page > 1 && toPreviousPage()}>上一页} + {projectList.length != 0 && page < Math.ceil(projectList.length / 10) && toNextPage()}>下一页}
@@ -69,6 +76,10 @@ const PersonInfor: React.FC<{}> = () => { itemLayout="horizontal" pagination={{ size: 'small', + onChange: page => { + setPage(page); + }, + current: page, showTotal: (total) => `共 ${total} 条`, pageSize: 10, }}