Skip to content

Commit 9b3ac7a

Browse files
authored
fix(Table): pagination are not displayed when using pageCount (#558)
1 parent b344d4a commit 9b3ac7a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Table/Table.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineComponent, h, toRefs, VNode, provide, mergeProps } from 'vue'
22
import { ElTable, ElTableColumn, ElPagination, useAttrs } from 'element-plus'
33
import { useSplitReactive } from '../composables/index'
4+
import { isUndefined } from '../utils/index'
45
import {
56
useTableBind,
67
useTableDefaultBind,
@@ -114,7 +115,12 @@ export default defineComponent({
114115
}),
115116
)
116117

117-
return [tableNode, props.total ? paginationNode : null]
118+
return [
119+
tableNode,
120+
!isUndefined(props.total) || !isUndefined(props.pageCount)
121+
? paginationNode
122+
: null,
123+
]
118124
}
119125

120126
return () => h('div', { class: 'pro-table' }, createDefault())

src/Table/index.test.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,21 @@ describe('Table', () => {
228228
:layout="layout"
229229
:columns="columns"
230230
:total="total"
231+
:page-count="pageCount"
231232
/>
232233
`,
233234
setup() {
234235
const total = ref(50)
236+
const pageCount = ref<number>()
235237
const currentPage = ref(1)
236238
const pageSize = ref(10)
237239
const layout = ref('prev, pager, next, sizes')
238-
return { columns, total, currentPage, pageSize, layout }
240+
return { columns, total, pageCount, currentPage, pageSize, layout }
239241
},
240242
})
241243
const vm = wrapper.vm as unknown as {
242-
total: number
244+
total?: number
245+
pageCount?: number
243246
currentPage: number
244247
pageSize: number
245248
layout: string
@@ -271,7 +274,13 @@ describe('Table', () => {
271274
)
272275

273276
await (vm.total = 0)
277+
expect(wrapper.find('.el-pagination').exists()).toBe(true)
278+
279+
await (vm.total = undefined)
274280
expect(wrapper.find('.el-pagination').exists()).toBe(false)
281+
282+
await (vm.pageCount = 5)
283+
expect(wrapper.find('.el-pagination').exists()).toBe(true)
275284
})
276285

277286
test.concurrent('align', async () => {

0 commit comments

Comments
 (0)