Sfoglia il codice sorgente

确认按钮添加防抖

tangning 2 giorni fa
parent
commit
7653b6bfec
1 ha cambiato i file con 9 aggiunte e 4 eliminazioni
  1. 9 4
      src/components/Modal/src/BasicModal.vue

+ 9 - 4
src/components/Modal/src/BasicModal.vue

@@ -50,7 +50,7 @@
 </template>
 <script lang="ts">
   import type { ModalProps, ModalMethods } from './typing';
-
+  import { debounce } from 'lodash-es';
   import {
     defineComponent,
     computed,
@@ -203,9 +203,14 @@
         }
       }
 
-      function handleOk(e: Event) {
-        emit('ok', e);
-      }
+      const handleOk = debounce(
+        (e: Event) => {
+          emit('ok', e);
+        },
+        200,
+        { leading: true, trailing: false },
+      );
+
 
       function handleHeightChange(height: string) {
         emit('height-change', height);