gpt4 book ai didi

reactjs - react 选择无法设置id

转载 作者:行者123 更新时间:2023-12-03 13:28:08 27 4
gpt4 key购买 nike

有一个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的方法,但是我不能直接为选择做这件事,这似乎很愚蠢。

最佳答案

在react-select >= 2版本中,设置id的prop称为inputId。像这样使用它:

<Select inputId="your-custom-id" />

关于reactjs - react 选择无法设置id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46453827/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com