fix: 当前页不为1时,修改页数后会导致多次调用getList方法问题

This commit is contained in:
chengyu 2024-12-10 21:06:22 +08:00
parent 72d6fd5a4e
commit 28ac2dd7b6
1 changed files with 4 additions and 2 deletions

View File

@ -25,22 +25,24 @@ export const useTable = (config: UseTableConfig) => {
const pageSize = ref(10)
const total = ref(0)
const dataList = ref<any[]>([])
let isPageSizeChange = false
watch(
() => currentPage.value,
() => {
methods.getList()
if (!isPageSizeChange) methods.getList()
isPageSizeChange = false
}
)
watch(
() => pageSize.value,
() => {
// 当前页不为1时修改页数后会导致多次调用getList方法
if (unref(currentPage) === 1) {
methods.getList()
} else {
currentPage.value = 1
isPageSizeChange = true
methods.getList()
}
}