mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-03-06 15:48:14 +00:00
fix(form): 初始值为0时会丢失
This commit is contained in:
parent
10c36c1980
commit
8956035e41
@ -115,7 +115,7 @@ const initValueItem = function (
|
||||
const { type, name } = item as ChildConfig;
|
||||
|
||||
if (isTableSelect(type) && name) {
|
||||
value[name] = initValue[name] || '';
|
||||
value[name] = initValue[name] ?? '';
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -124,18 +124,14 @@ const initValueItem = function (
|
||||
// 这种情况比较多,提前结束
|
||||
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' ? initValue[name] : initValue[name];
|
||||
}
|
||||
value[name] = type === 'number' ? Number(initValue[name]) : initValue[name];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (names) {
|
||||
return names.forEach((n: string) => (value[n] = initValue[n] || ''));
|
||||
return names.forEach((n: string) => (value[n] = initValue[n] ?? ''));
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user