mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:18:03 +08:00
不在 field 中也可以自己查找变量
This commit is contained in:
parent
43c2134212
commit
b43a151acc
@ -5,6 +5,7 @@ import {Api, SchemaNode, PlainObject} from '../types';
|
||||
import {filter} from '../utils/tpl';
|
||||
import cx from 'classnames';
|
||||
import Switch from '../components/Switch';
|
||||
import { resolveVariable } from '../utils/tpl-builtin';
|
||||
|
||||
export interface SwitchProps extends RendererProps {
|
||||
className?: string;
|
||||
@ -47,18 +48,24 @@ export class SwitchField extends React.Component<SwitchProps, object> {
|
||||
const {
|
||||
className,
|
||||
classPrefix: ns,
|
||||
value,
|
||||
placeholder,
|
||||
trueValue,
|
||||
falseValue,
|
||||
onQuickChange,
|
||||
option,
|
||||
disabled,
|
||||
name,
|
||||
data
|
||||
} = this.props;
|
||||
|
||||
let value = this.props.value;
|
||||
let viewValue: React.ReactNode = <span className="text-muted">{placeholder}</span>;
|
||||
let showOption = false;
|
||||
|
||||
if (value === void 0 && name) {
|
||||
value = resolveVariable(name, data);
|
||||
}
|
||||
|
||||
if (value == trueValue || value == falseValue) {
|
||||
showOption = !!option;
|
||||
viewValue = (
|
||||
|
Loading…
Reference in New Issue
Block a user