Browse Source

Merge pull request #571 from Chengyu531/master

fix: 当前页不为1时,修改页数后会导致多次调用getList方法问题
Archer 4 months ago
parent
commit
9c91d8d68e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/hooks/web/useTable.ts

+ 4 - 2
src/hooks/web/useTable.ts

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