From 7f70cb15d035f0c233b9e62b9e43aa985317c908 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 04 十一月 2024 10:22:45 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/map/insight/agv/useCoolHook.js |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/zy-acs-flow/src/map/insight/agv/useCoolHook.js b/zy-acs-flow/src/map/insight/agv/useCoolHook.js
index f741bd7..daf2611 100644
--- a/zy-acs-flow/src/map/insight/agv/useCoolHook.js
+++ b/zy-acs-flow/src/map/insight/agv/useCoolHook.js
@@ -22,6 +22,7 @@
                 })))
             } else {
                 console.error(msg);
+                setOptions([]);
             }
         } catch (error) {
             console.error(error.message);
@@ -32,16 +33,21 @@
     const debouncedFetch = useCallback(debounce(fetchData, 300), [url]);
 
     useEffect(() => {
-        if (inputValue) {
-            debouncedFetch(inputValue);
-        } else {
-            setOptions([]);
-        }
+        // console.log(inputValue, url)
+        // if (inputValue) {
+        //     debouncedFetch(inputValue);
+        // } else {
+        //     setOptions([]);
+        // }
+        debouncedFetch(inputValue);
     }, [inputValue, debouncedFetch]);
+
+    const resetInput = () => setInputValue('');
 
     return {
         options,
         setInputValue,
+        resetInput,
     };
 }
 

--
Gitblit v1.9.1