Questions tagged «react-select»

13
如何在react-select中设置默认值
我在使用react-select时遇到问题。我使用redux表单,并且使我的react-select组件与redux表单兼容。这是代码: const MySelect = props => ( <Select {...props} value={props.input.value} onChange={value => props.input.onChange(value)} onBlur={() => props.input.onBlur(props.input.value)} options={props.options} placeholder={props.placeholder} selectedValue={props.selectedValue} /> ); 这里是我如何渲染它: <div className="select-box__container"> <Field id="side" name="side" component={SelectInput} options={sideOptions} clearable={false} placeholder="Select Side" selectedValue={label: 'Any', value: 'Any'} /> </div> 但是问题是我的下拉菜单没有我希望的默认值。我做错了什么?有任何想法吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.