mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
支持 labelField
This commit is contained in:
parent
95aa42d0f8
commit
1512f43d58
@ -31,6 +31,7 @@ interface RadioProps extends OptionProps {
|
||||
onChange?: Function;
|
||||
columnsCount: number;
|
||||
itemClassName?: string;
|
||||
labelField?: string;
|
||||
labelClassName?: string;
|
||||
classPrefix: string;
|
||||
classnames: ClassNamesFn;
|
||||
@ -38,6 +39,7 @@ interface RadioProps extends OptionProps {
|
||||
|
||||
export class Radios extends React.Component<RadioProps, any> {
|
||||
static defaultProps = {
|
||||
type: 'radio',
|
||||
joinValues: true,
|
||||
clearable: false,
|
||||
columnsCount: 1 // 一行显示一个
|
||||
@ -102,7 +104,8 @@ export class Radios extends React.Component<RadioProps, any> {
|
||||
inline,
|
||||
itemClassName,
|
||||
classnames: cx,
|
||||
labelClassName
|
||||
labelClassName,
|
||||
labelField
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@ -117,7 +120,7 @@ export class Radios extends React.Component<RadioProps, any> {
|
||||
inline={inline}
|
||||
labelClassName={labelClassName}
|
||||
>
|
||||
{option.label}
|
||||
{option[labelField || 'label']}
|
||||
</Checkbox>
|
||||
);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export default class CheckboxesControl extends React.Component<
|
||||
}
|
||||
|
||||
renderGroup(option: Option, index: number) {
|
||||
const {classnames: cx} = this.props;
|
||||
const {classnames: cx, labelField} = this.props;
|
||||
|
||||
return (
|
||||
<div
|
||||
@ -52,7 +52,7 @@ export default class CheckboxesControl extends React.Component<
|
||||
<label
|
||||
className={cx('CheckboxesControl-groupLabel', option.labelClassName)}
|
||||
>
|
||||
{option.label}
|
||||
{option[labelField || 'label']}
|
||||
</label>
|
||||
|
||||
{option.children && option.children.length
|
||||
|
@ -60,7 +60,8 @@ export default class ListControl extends React.Component<ListProps, any> {
|
||||
imageClassName,
|
||||
submitOnDBClick,
|
||||
itemSchema,
|
||||
data
|
||||
data,
|
||||
labelField
|
||||
} = this.props;
|
||||
|
||||
let body: JSX.Element | null = null;
|
||||
@ -94,12 +95,15 @@ export default class ListControl extends React.Component<ListProps, any> {
|
||||
key="image"
|
||||
className={cx('ListControl-itemImage', imageClassName)}
|
||||
>
|
||||
<img src={option.image} alt={option.label} />
|
||||
<img
|
||||
src={option.image}
|
||||
alt={option[labelField || 'label']}
|
||||
/>
|
||||
</div>
|
||||
) : null,
|
||||
option.label ? (
|
||||
option[labelField || 'label'] ? (
|
||||
<div key="label" className={cx('ListControl-itemLabel')}>
|
||||
{option.label}
|
||||
{option[labelField || 'label']}
|
||||
</div>
|
||||
) : null
|
||||
// {/* {option.tip ? (<div className={`${ns}ListControl-tip`}>{option.tip}</div>) : null} */}
|
||||
|
@ -72,8 +72,8 @@ export default class RadiosControl extends React.Component<RadiosProps, any> {
|
||||
disabled={disabled}
|
||||
onChange={this.handleChange}
|
||||
joinValues={joinValues}
|
||||
extractValue={extractValue}
|
||||
delimiter={delimiter}
|
||||
extractValue={extractValue!}
|
||||
delimiter={delimiter!}
|
||||
labelClassName={labelClassName}
|
||||
placeholder={placeholder}
|
||||
options={options}
|
||||
|
Loading…
Reference in New Issue
Block a user