mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 13:09:07 +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 {filter} from '../utils/tpl';
|
||||||
import cx from 'classnames';
|
import cx from 'classnames';
|
||||||
import Switch from '../components/Switch';
|
import Switch from '../components/Switch';
|
||||||
|
import { resolveVariable } from '../utils/tpl-builtin';
|
||||||
|
|
||||||
export interface SwitchProps extends RendererProps {
|
export interface SwitchProps extends RendererProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -47,18 +48,24 @@ export class SwitchField extends React.Component<SwitchProps, object> {
|
|||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
classPrefix: ns,
|
classPrefix: ns,
|
||||||
value,
|
|
||||||
placeholder,
|
placeholder,
|
||||||
trueValue,
|
trueValue,
|
||||||
falseValue,
|
falseValue,
|
||||||
onQuickChange,
|
onQuickChange,
|
||||||
option,
|
option,
|
||||||
disabled,
|
disabled,
|
||||||
|
name,
|
||||||
|
data
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
let value = this.props.value;
|
||||||
let viewValue: React.ReactNode = <span className="text-muted">{placeholder}</span>;
|
let viewValue: React.ReactNode = <span className="text-muted">{placeholder}</span>;
|
||||||
let showOption = false;
|
let showOption = false;
|
||||||
|
|
||||||
|
if (value === void 0 && name) {
|
||||||
|
value = resolveVariable(name, data);
|
||||||
|
}
|
||||||
|
|
||||||
if (value == trueValue || value == falseValue) {
|
if (value == trueValue || value == falseValue) {
|
||||||
showOption = !!option;
|
showOption = !!option;
|
||||||
viewValue = (
|
viewValue = (
|
||||||
|
Loading…
Reference in New Issue
Block a user