Переглянути джерело

fix(form): fix the problem of form props monitoring close #322

Vben 4 роки тому
батько
коміт
83a3460356
2 змінених файлів з 18 додано та 5 видалено
  1. 7 0
      CHANGELOG.zh_CN.md
  2. 11 5
      src/components/Form/src/hooks/useForm.ts

+ 7 - 0
CHANGELOG.zh_CN.md

@@ -1,3 +1,10 @@
+## Wip
+
+### 🐛 Bug Fixes
+
+- 修复`Description`已知问题
+- 修复`BasicForm`已知问题
+
 ## 2.0.2 (2021-03-04)
 
 ### ✨ Refactor

+ 11 - 5
src/components/Form/src/hooks/useForm.ts

@@ -1,4 +1,4 @@
-import { ref, onUnmounted, unref, nextTick, watchEffect } from 'vue';
+import { ref, onUnmounted, unref, nextTick, watch } from 'vue';
 
 import { isInSetup } from '/@/utils/helper/vueHelper';
 import { isProdMode } from '/@/utils/env';
@@ -39,12 +39,18 @@ export function useForm(props?: Props): UseFormReturnType {
     if (unref(loadedRef) && isProdMode() && instance === unref(formRef)) return;
 
     formRef.value = instance;
-
     loadedRef.value = true;
 
-    watchEffect(() => {
-      props && instance.setProps(getDynamicProps(props));
-    });
+    watch(
+      () => props,
+      () => {
+        props && instance.setProps(getDynamicProps(props));
+      },
+      {
+        immediate: true,
+        deep: true,
+      }
+    );
   }
 
   const methods: FormActionType = {