Răsfoiți Sursa

修复我的任务重置按钮点击不调用接口问题

wyn 3 luni în urmă
părinte
comite
af6d325ae0
1 a modificat fișierele cu 11 adăugiri și 2 ștergeri
  1. 11 2
      src/components/MyTask.tsx

+ 11 - 2
src/components/MyTask.tsx

@@ -315,12 +315,21 @@ export default function MyTask() {
 
   // 重置
   const handleReset = () => {
+    // 重置本地搜索关键字
     setSearchKey('');
-    setQueryParams({
+
+    // 构造重置后的查询参数
+    const resetParams: MyTaskPageParam = {
       ...queryParams,
       pageNo: 1,
       key: undefined,
-    });
+    };
+
+    // 更新查询参数(触发 useEffect 中的列表刷新逻辑)
+    setQueryParams(resetParams);
+
+    // 立即调用一次列表接口,确保点击重置时立刻刷新列表
+    getList(resetParams);
   };
 
   // 默认表单配置