[英]react-select cannot set id
有一个react-select组件并且id字段没有设置? 是否可以设置ID?
<Select
id={field}
className="reqform-project-dropdown"
{...f.props(field)}
disabled={
readOnly ||
onEdit ||
f.props(field).read_only
}
clearable={false}
options={this.props.common.tests}
onChange={this.handleProjChange.bind(this, field,
f.props(field).multiple,
'test_req_unique_prefix')}
labelKey="test_name"
valueKey="test_req_unique_prefix"
/>
我已经设置了父div的id,但看起来很傻我不能直接为select做。
在inputId
= 2的react-select中,设置id的prop称为inputId
。 像这样使用它:
<Select inputId="your-custom-id" />
您可以像在文档中一样使用inputProps
prop。
如果你想要的是在点击相应的标签时焦点,在inputProps
传递id
应该有效。
<label htmlFor={'fieldId'} />
<Select inputProps={{ id: 'fieldId' }} /> // should be an object
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.