[英]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.