Redux-Form中的可编辑组合框 [英] Editable combo box in Redux-Form
本文介绍了Redux-Form中的可编辑组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
与此线程类似的内容:如何在HTML/Javascript中创建可编辑的组合框?
Something to similar with this thread: How can I create an editable combo box in HTML/Javascript?
是否可以在Redux-Form中使用组合框表单?
Is it possible to have a combo-box form in Redux-Form?
推荐答案
这对我有用:
<Field
options={[
{value: 1, text: 'Option1'},
{value: 2, text: 'Option2'}
]}
component={Select}
label="My select question"
className="col-md-6"
/>
const Select = ({input, options, label, error}) => {
if (error && error.length > 0) {
className += " " + 'has-error'
}
return (
<div className={className}>
{label && <label htmlFor={input.name}>{label}</label>}
<select {...input} >
{options.map(function (option, i) {
return (
<option
value={option.value}
key={i}
>
{option.text}
</option>)
})}
</select>
{error && <div className="alert alert-danger">{error}</div>}
</div>
)
}
这篇关于Redux-Form中的可编辑组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文