Commit 83a34603562e6358203b834b8feb59b0b44dbbcd
1 parent
ce93e46f
fix(form): fix the problem of form props monitoring close #322
Showing
2 changed files
with
18 additions
and
5 deletions
CHANGELOG.zh_CN.md
src/components/Form/src/hooks/useForm.ts
1 | -import { ref, onUnmounted, unref, nextTick, watchEffect } from 'vue'; | |
1 | +import { ref, onUnmounted, unref, nextTick, watch } from 'vue'; | |
2 | 2 | |
3 | 3 | import { isInSetup } from '/@/utils/helper/vueHelper'; |
4 | 4 | import { isProdMode } from '/@/utils/env'; |
... | ... | @@ -39,12 +39,18 @@ export function useForm(props?: Props): UseFormReturnType { |
39 | 39 | if (unref(loadedRef) && isProdMode() && instance === unref(formRef)) return; |
40 | 40 | |
41 | 41 | formRef.value = instance; |
42 | - | |
43 | 42 | loadedRef.value = true; |
44 | 43 | |
45 | - watchEffect(() => { | |
46 | - props && instance.setProps(getDynamicProps(props)); | |
47 | - }); | |
44 | + watch( | |
45 | + () => props, | |
46 | + () => { | |
47 | + props && instance.setProps(getDynamicProps(props)); | |
48 | + }, | |
49 | + { | |
50 | + immediate: true, | |
51 | + deep: true, | |
52 | + } | |
53 | + ); | |
48 | 54 | } |
49 | 55 | |
50 | 56 | const methods: FormActionType = { | ... | ... |