소스 검색

fix(drawer): openDrawer is not normal in some cases

修复BasicDrawer在设置其它属性时可能会影响visible状态的问题
无木 3 년 전
부모
커밋
941ad59759
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 4
      src/components/Drawer/src/BasicDrawer.vue

+ 7 - 4
src/components/Drawer/src/BasicDrawer.vue

@@ -37,7 +37,6 @@
     defineComponent,
     defineComponent,
     ref,
     ref,
     computed,
     computed,
-    watchEffect,
     watch,
     watch,
     unref,
     unref,
     nextTick,
     nextTick,
@@ -135,9 +134,13 @@
         return !!unref(getProps)?.loading;
         return !!unref(getProps)?.loading;
       });
       });
 
 
-      watchEffect(() => {
-        visibleRef.value = props.visible;
-      });
+      watch(
+        () => props.visible,
+        (newVal, oldVal) => {
+          if (newVal != oldVal) visibleRef.value = newVal;
+        },
+        { deep: true }
+      );
 
 
       watch(
       watch(
         () => visibleRef.value,
         () => visibleRef.value,