Skip to content

Commit

Permalink
fix: multiple requests when pageSize change and currentPage isn't 1
Browse files Browse the repository at this point in the history
  • Loading branch information
xiterjia committed May 17, 2022
1 parent 08bfacc commit f71a250
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/components/Table/src/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default defineComponent({
// 注册
onMounted(() => {
emit('register', unref(elTableRef)?.$parent, unref(elTableRef))
const tableRef = unref(elTableRef)
emit('register', tableRef?.$parent, elTableRef)
})
const pageSizeRef = ref(props.pageSize)
Expand Down Expand Up @@ -167,9 +168,9 @@ export default defineComponent({
}
const renderTableExpand = () => {
const { align, headerAlign } = unref(getProps)
const { align, headerAlign, expand } = unref(getProps)
// 渲染展开行
return unref(getProps).expand ? (
return expand ? (
<ElTableColumn type="expand" align={align} headerAlign={headerAlign}>
{{
// @ts-ignore
Expand Down
9 changes: 7 additions & 2 deletions src/hooks/web/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ export const useTable = <T, K, L extends AxiosConfig = AxiosConfig>(
watch(
() => tableObject.pageSize,
() => {
tableObject.currentPage = 1
methods.getList()
// 当前页不为1时,修改页数后会导致多次调用getList方法
if (tableObject.currentPage === 1) {
methods.getList()
} else {
tableObject.currentPage = 1
methods.getList()
}
}
)

Expand Down

0 comments on commit f71a250

Please sign in to comment.