-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: pagination #861
Merged
Merged
refactor: pagination #861
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
7e7d8b4
chore: prevText -> prev
eiinu 58b233b
chore: nextText -> next
eiinu bb5ca00
chore: forceEllipses -> ellipse
eiinu 56ce9e6
chore: showPageSize -> itemSize
eiinu 11117aa
chore: itemsPerpage -> pageSize
eiinu 6b5c22c
chore: totalitems -> total
eiinu ae55ac5
chore: pageNodeRender -> itemRender
eiinu d3a4087
chore: pageNodeRender -> itemRender
eiinu ee3bade
chore: 移除 pageCount
eiinu a552160
chore: modelValue -> current, defaultValue 非受控
eiinu 15ee2c9
test: 增加单元测试
eiinu 8c64cc9
test: 更新单元测试
eiinu ba9a6d6
fix: update
eiinu d0bcb53
fix: update
eiinu 81b5061
Merge branch 'next' into v2.0-pagination
eiinu e6d8711
fix: update
eiinu 81f9ef4
fix: update
eiinu b3aa06e
fix: update
eiinu 2974a96
fix: update
eiinu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,98 +6,117 @@ import { useTranslate } from '@/sites/assets/locale/taro' | |
import Header from '@/sites/components/header' | ||
|
||
interface T { | ||
ce5c5446: string | ||
c38a08ef: string | ||
b840c88f: string | ||
a74a1fd4: string | ||
basic: string | ||
simple: string | ||
ellipse: string | ||
custom: string | ||
uncontrolled: string | ||
} | ||
|
||
const PaginationDemo = () => { | ||
const [translated] = useTranslate<T>({ | ||
'zh-CN': { | ||
ce5c5446: '基础用法', | ||
c38a08ef: '简单模式', | ||
b840c88f: '显示省略号', | ||
a74a1fd4: '自定义按钮', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 改完挺好,但是为啥要改呢。。 |
||
basic: '基础用法', | ||
simple: '简单模式', | ||
ellipse: '显示省略号', | ||
custom: '自定义按钮', | ||
uncontrolled: '非受控方式', | ||
}, | ||
'zh-TW': { | ||
ce5c5446: '基礎用法', | ||
c38a08ef: '簡單模式', | ||
b840c88f: '顯示省略號', | ||
a74a1fd4: '自定義按鈕', | ||
basic: '基礎用法', | ||
simple: '簡單模式', | ||
ellipse: '顯示省略號', | ||
custom: '自定義按鈕', | ||
uncontrolled: '非受控方式', | ||
}, | ||
'en-US': { | ||
ce5c5446: 'Basic usage', | ||
c38a08ef: 'Simple mode', | ||
b840c88f: 'Show ellipsis', | ||
a74a1fd4: 'Custom button', | ||
basic: 'Basic usage', | ||
simple: 'Simple mode', | ||
ellipse: 'Show ellipsis', | ||
custom: 'Custom button', | ||
uncontrolled: 'Uncontrolled mode', | ||
}, | ||
}) | ||
const [currentPage1, setCurrent1] = useState(1) | ||
const [currentPage2, setCurrent2] = useState(1) | ||
const [currentPage3, setCurrent3] = useState(1) | ||
const [currentPage4, setCurrent4] = useState(3) | ||
const pageChange1 = (v: any) => { | ||
const pageChange1 = (v: number) => { | ||
const c = v | ||
setCurrent1(c) | ||
} | ||
const pageChange2 = (v: any) => { | ||
const pageChange2 = (v: number) => { | ||
const c = v | ||
setCurrent2(c) | ||
} | ||
const pageChange3 = (v: any) => { | ||
const pageChange3 = (v: number) => { | ||
const c = v | ||
setCurrent3(c) | ||
} | ||
const pageChange4 = (v: any) => { | ||
const pageChange4 = (v: number) => { | ||
const c = v | ||
setCurrent4(c) | ||
} | ||
const pageNodeRender = (item: any) => { | ||
const itemRender = (item: any) => { | ||
return <div>{item.number === 3 ? 'hot' : item.text}</div> | ||
} | ||
const pageChange5 = (v: number) => { | ||
const c = v | ||
setCurrent3(c) | ||
} | ||
return ( | ||
<> | ||
<Header /> | ||
<div className={`demo ${Taro.getEnv() === 'WEB' ? 'web' : ''}`}> | ||
<h2>{translated.ce5c5446}</h2> | ||
<h2>{translated.basic}</h2> | ||
<Cell> | ||
<Pagination | ||
modelValue={currentPage1} | ||
totalItems="20" | ||
itemsPerPage="5" | ||
value={currentPage1} | ||
total={20} | ||
pageSize={5} | ||
onChange={pageChange1} | ||
/> | ||
</Cell> | ||
<h2>{translated.c38a08ef}</h2> | ||
<h2>{translated.simple}</h2> | ||
<Cell> | ||
<Pagination | ||
modelValue={currentPage2} | ||
pageCount={12} | ||
value={currentPage2} | ||
total={12} | ||
pageSize={1} | ||
mode="simple" | ||
onChange={pageChange2} | ||
/> | ||
</Cell> | ||
<h2>{translated.b840c88f}</h2> | ||
<h2>{translated.ellipse}</h2> | ||
<Cell> | ||
<Pagination | ||
modelValue={currentPage3} | ||
totalItems="125" | ||
showPageSize="3" | ||
forceEllipses | ||
value={currentPage3} | ||
total={125} | ||
itemSize={2} | ||
ellipse | ||
onChange={pageChange3} | ||
/> | ||
</Cell> | ||
<h2>{translated.a74a1fd4}</h2> | ||
<h2>{translated.custom}</h2> | ||
<Cell> | ||
<Pagination | ||
modelValue={currentPage4} | ||
totalItems="500" | ||
showPageSize="5" | ||
value={currentPage4} | ||
total={500} | ||
itemSize={5} | ||
onChange={pageChange4} | ||
prevText={<Left />} | ||
nextText={<Right />} | ||
pageNodeRender={pageNodeRender} | ||
prev={<Left />} | ||
next={<Right />} | ||
itemRender={itemRender} | ||
/> | ||
</Cell> | ||
<h2>{translated.uncontrolled}</h2> | ||
<Cell> | ||
<Pagination | ||
defaultValue={15} | ||
total={500} | ||
pageSize={10} | ||
itemSize={3} | ||
onChange={pageChange5} | ||
/> | ||
</Cell> | ||
</div> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pagination 组件的 defaultValue 是不是改成 defaultCurrent ,和 current 对应