【发布时间】:2019-07-05 19:06:16
【问题描述】:
其实我想用 react-quill 组件作为 antd Form.item 的一部分。
<ReactQuill
ref='editor'
onChange={this.onChange}
/>
上面的组件是 react-quill 基础组件。 我需要像下面提到的那样使用
<Field
label="Departure"
placeholder="Departure"
name="departure"
component={}
/>
在<Field />之上,其实是从redux form导入props,也就是我在AntdForm中使用的Form.Item如下图
import {
Form,
Input,
} from 'antd'
const FormItem = Form.Item;
const makeField = Component => ({
input,
meta,
children,
hasFeedback,
label,
labelRight,
...rest
}) => {
const hasError = meta.touched && meta.invalid;
return (
<FormItem
{...formItemLayout}
label={label}
validateStatus={hasError ? 'error' : 'success'}
hasFeedback={hasFeedback && hasError}
help={hasError && meta.error}
>
<Component {...input} {...rest}>
{children}
</Component>
{labelRight && (
<span style={{ color: (rest.disabled && '#5a5a5a') || '#9e9e9e' }}>
{labelRight}
</span>
)}
</FormItem>
);
};
export const AInput = makeField(Input);
在表单中的使用
<Field
label="Destination"
placeholder="Destination"
name="destination"
component={AInput}
/>
如上所示,我如何在Form.Item 中使用antd Input 而不是在Redux-Form Field 中渲染。同样,我需要使用React-Quill 组件。
【问题讨论】:
标签: reactjs antd quill ant-design-pro