修复FormBuilder的部分判断 || 改成 ??

master
LiuJiaNan 2025-10-24 17:51:03 +08:00
parent 96fe1443b2
commit 2ee481d817
1 changed files with 4 additions and 4 deletions

View File

@ -90,7 +90,7 @@ const FormItemsRenderer = ({
// 支持动态计算 required
const required = typeof option.required === "function"
? option.required(form.getFieldsValue())
: (option.required || true);
: (option.required ?? true);
if (required) {
const isBlurTrigger = !option.render || [
@ -274,7 +274,7 @@ const FormItemsRenderer = ({
}
// 如果配置了 shouldUpdate 或 dependencies使用 Form.Item 的联动机制
if (option.shouldUpdate || option.dependencies || option?.componentProps?.shouldUpdate || option?.componentProps?.dependencies) {
if ((option.shouldUpdate ?? option.dependencies) || (option?.componentProps?.shouldUpdate ?? option?.componentProps?.dependencies)) {
return (
option.customizeRender
? (renderFormControl(option))
@ -282,14 +282,14 @@ const FormItemsRenderer = ({
<Col key={option.name || index} span={itemSpan} style={style}>
<Form.Item
noStyle
shouldUpdate={option.shouldUpdate || option?.componentProps?.shouldUpdate}
shouldUpdate={option.shouldUpdate ?? option?.componentProps?.shouldUpdate}
dependencies={option.dependencies || option?.componentProps?.dependencies}
>
{(form) => {
// 支持动态计算 hidden
const hidden = typeof option.hidden === "function"
? option.hidden(form.getFieldsValue())
: (option.hidden || false);
: (option.hidden ?? false);
if (hidden)
return null;