我是使用redux-form中的field-arrays,并且需要在我的表单中添加一个可搜索的下拉菜单。我知道一个普通的下拉菜单可以这样实现,
但这不是可搜索的下拉列表。即使我要使用它,它只提供基本的HTML选择器,我怎么能够应用CSS样式来使其与其他Bootstrap元素匹配呢?
为了拥有一个可搜索的下拉列表,我正在使用react-select包。我尝试做的是;
这个功能没有正常工作,只有在下拉菜单被激活时(被点击时)值才会存储在redux-store中,在失焦事件中会丢失该值。我做错了什么? 在redux-form中是否可能拥有可搜索的下拉列表?
<Field name={`${object}.method`} component="select" validate={required} id={`${object}.key`}>
<option value="id">id</option>
<option value="css">css</option>
<option value="xpath">xpath</option>
<option value="binding">binding</option>
<option value="model">model</option>
</Field>
但这不是可搜索的下拉列表。即使我要使用它,它只提供基本的HTML选择器,我怎么能够应用CSS样式来使其与其他Bootstrap元素匹配呢?
为了拥有一个可搜索的下拉列表,我正在使用react-select包。我尝试做的是;
<Field
name={`${object}.method`}
type='text'
component={this.renderDropdown}
label="Method"
validate={required}
id={`${object}.key`}
valueField='value'
/>
renderDropdown = ({ input, id, valueField, meta: { touched, error }, ...props }) => {
return (
<React.Fragment>
<div className='align-inline object-field-length'>
<Select {...input} id={id} value={input.value.value} onChange={input.onChange}
options={[
{ value: 'id', label: 'id' },
{ value: 'css', label: 'css' },
{ value: 'xpath', label: 'xpath' },
{ value: 'binding', label: 'binding' },
{ value: 'model', label: 'model' },
]}
/>
</div>
</React.Fragment>
)
};
这个功能没有正常工作,只有在下拉菜单被激活时(被点击时)值才会存储在redux-store中,在失焦事件中会丢失该值。我做错了什么? 在redux-form中是否可能拥有可搜索的下拉列表?