Skip to content

Commit

Permalink
fix: 修复编辑器中switch组件默认值回显不对问题 (baidu#9522)
Browse files Browse the repository at this point in the history
* fix: 修复编辑器中switch组件默认值回显不对问题

* 修改为isExpression方法

---------

Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
  • Loading branch information
qkiroc and qkiroc committed Jan 25, 2024
1 parent d9d9231 commit 70c8d30
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/amis-editor/src/plugin/Form/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
RendererPluginAction,
RendererPluginEvent
} from 'amis-editor-core';
import {isExpression} from 'amis-core';

export class SwitchControlPlugin extends BasePlugin {
static id = 'SwitchControlPlugin';
Expand Down Expand Up @@ -202,12 +203,10 @@ export class SwitchControlPlugin extends BasePlugin {
: value;
},
pipeOut: (value: any, origin: any, data: any) => {
// 如果是表达式,直接返回
if (isExpression(value)) return value;
const {trueValue = true, falseValue = false} = data || {};
return value && value === trueValue
? trueValue
: value && value !== falseValue
? value
: falseValue;
return value ? trueValue : falseValue;
}
}),
getSchemaTpl('labelRemark'),
Expand Down

0 comments on commit 70c8d30

Please sign in to comment.