mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-07 13:48:31 +08:00
fix(pagination): page count is not correct when item-count
is 0
This commit is contained in:
parent
199061c9b4
commit
47761e3605
@ -6,6 +6,10 @@
|
||||
|
||||
- `n-rate` add `allow-half` prop.
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix `n-pagination` page count is not correct when `item-count` is 0.
|
||||
|
||||
## 2.15.4 (2021-07-09)
|
||||
|
||||
### Feats
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
- `n-rate` 新增 `allow-half` 属性
|
||||
|
||||
### Fixes
|
||||
|
||||
- 修复 `n-pagination` `item-count` 为 0 时页数不对
|
||||
|
||||
## 2.15.4 (2021-07-09)
|
||||
|
||||
### Feats
|
||||
|
@ -125,7 +125,7 @@ export default defineComponent({
|
||||
// item count has high priority, for it can affect prefix slot rendering
|
||||
const { itemCount } = props
|
||||
if (itemCount !== undefined) {
|
||||
return Math.ceil(itemCount / mergedPageSizeRef.value)
|
||||
return Math.max(1, Math.ceil(itemCount / mergedPageSizeRef.value))
|
||||
}
|
||||
const { pageCount } = props
|
||||
if (pageCount !== undefined) return pageCount
|
||||
|
@ -5,4 +5,17 @@ describe('n-pagination', () => {
|
||||
it('should work with import on demand', () => {
|
||||
mount(NPagination)
|
||||
})
|
||||
it('props.itemCount', async () => {
|
||||
const wrapper = mount(NPagination, {
|
||||
props: {
|
||||
itemCount: 1,
|
||||
pageSize: 10
|
||||
}
|
||||
})
|
||||
expect(wrapper.findAll('.n-pagination-item').length).toEqual(3)
|
||||
await wrapper.setProps({
|
||||
itemCount: 11
|
||||
})
|
||||
expect(wrapper.findAll('.n-pagination-item').length).toEqual(4)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user