有一个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设置,这似乎很愚蠢。
发布于 2017-09-28 04:18:28
您可以像在文档中一样使用inputProps属性。
如果您希望在单击相应标签时获得焦点,则在inputProps中传递id应该是可行的。
<label htmlFor={'fieldId'} />
<Select inputProps={{ id: 'fieldId' }} /> // should be an object发布于 2019-02-25 19:42:39
在react-select的>= 2版本中,设置id的属性称为inputId。像这样使用它:
<Select inputId="your-custom-id" />https://stackoverflow.com/questions/46453827
复制相似问题