From b536eba81c33f8e532179b69072ea7c5d4033235 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Wed, 26 Nov 2025 16:38:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(form):=20=E7=94=9F=E6=88=90=E8=A1=A8?= =?UTF-8?q?=E5=8D=95values=E6=97=B6=E5=B0=86initValus=E6=B7=B1=E6=8B=B7?= =?UTF-8?q?=E8=B4=9D,=E9=81=BF=E5=85=8D=E4=BF=AE=E6=94=B9=E5=88=B0?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E7=9A=84=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/form/src/utils/form.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/form/src/utils/form.ts b/packages/form/src/utils/form.ts index 8836e80b..7596f199 100644 --- a/packages/form/src/utils/form.ts +++ b/packages/form/src/utils/form.ts @@ -16,7 +16,6 @@ * limitations under the License. */ -import { toRaw } from 'vue'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import { cloneDeep } from 'lodash-es'; @@ -121,12 +120,12 @@ const initValueItem = function ( asyncLoadConfig(value, initValue, item as HtmlField); // 这种情况比较多,提前结束 - if (name && !items && typeof initValue[name] !== 'undefined') { + if (name && !items && typeof initValue?.[name] !== 'undefined') { if (typeof value[name] === 'undefined') { if (type === 'number') { value[name] = Number(initValue[name]); } else { - value[name] = typeof initValue[name] === 'object' ? cloneDeep(initValue[name]) : initValue[name]; + value[name] = typeof initValue[name] === 'object' ? initValue[name] : initValue[name]; } } @@ -281,13 +280,15 @@ export const initValue = async ( ) => { if (!Array.isArray(config)) throw new Error('config应该为数组'); - let valuesTmp = createValues(mForm, config, toRaw(initValues), {}); + const initValuesCopy = cloneDeep(initValues); + + let valuesTmp = createValues(mForm, config, initValuesCopy, {}); const [firstForm] = config as [ContainerCommonConfig]; if (firstForm && typeof firstForm.onInitValue === 'function') { valuesTmp = await firstForm.onInitValue(mForm, { formValue: valuesTmp, - initValue: initValues, + initValue: initValuesCopy, }); }