调整一下itemRender参数

This commit is contained in:
2betop 2020-06-12 11:15:55 +08:00
parent d8f6aa6655
commit d3d8905299

View File

@ -13,12 +13,12 @@ export interface ArrayInputProps extends ThemeProps, LocaleProps {
value?: Array<any>; value?: Array<any>;
onChange?: (value: Array<any>) => void; onChange?: (value: Array<any>) => void;
placeholder: string; placeholder: string;
itemRender: ( itemRender: (props: {
value: any, value: any;
onChange: (value: any) => void, onChange: (value: any) => void;
index: number, index: number;
disabled?: boolean disabled?: boolean;
) => JSX.Element; }) => JSX.Element;
itemInitalValue?: any; itemInitalValue?: any;
maxLength?: number; maxLength?: number;
minLength?: number; minLength?: number;
@ -33,9 +33,15 @@ export interface ArrayInputProps extends ThemeProps, LocaleProps {
export class ArrayInput extends React.Component<ArrayInputProps> { export class ArrayInput extends React.Component<ArrayInputProps> {
static defaultProps = { static defaultProps = {
placeholder: '<空>', placeholder: '<空>',
itemRender: (value: any, onChange: (value: any) => void, index: number) => ( itemRender: ({
<InputBox value={value} onChange={onChange} /> value,
) onChange
}: {
value: any;
onChange: (value: any) => void;
index: number;
disabled?: boolean;
}) => <InputBox value={value} onChange={onChange} />
}; };
id: string = guid(); id: string = guid();
@ -144,12 +150,12 @@ export class ArrayInput extends React.Component<ArrayInputProps> {
</a> </a>
) : null} ) : null}
{itemRender( {itemRender({
value, value,
this.handleItemOnChange.bind(this, index), onChange: this.handleItemOnChange.bind(this, index),
index, index,
disabled disabled
)} })}
{removable !== false && {removable !== false &&
!disabled && !disabled &&