Browse Source

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

修复BasicDrawer在设置其它属性时可能会影响visible状态的问题
无木 3 years ago
parent
commit
941ad59759
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/components/Drawer/src/BasicDrawer.vue

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

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