gpt4 book ai didi

javascript - propType 失败 : The prop `id` is required to make `Dropdown` accessible for users of assistive technologies such as screen readers

转载 作者:搜寻专家 更新时间:2023-11-01 04:22:47 25 4
gpt4 key购买 nike

这是我使用 react-bootstrap 渲染下拉菜单的代码,

render(){
return(
<SplitButton title={this.state.title}>
{Object.keys(dict).map(key => <MenuItem id={dict[key]} key={dict[key]} href={`#${dict[key]}`} onSelect={() => this.onTargetSelect(key,dict[key])}>{key}</MenuItem>)}
</SplitButton>
);
}

我得到以下错误,

Failed propType: The prop `id` is required to make `Dropdown` accessible for users of assistive technologies such as screen readers. Check the render method of `Uncontrolled(Dropdown)`.

我没有 id propType。

我做错了什么?

最佳答案

dropDowns 需要一个有效的 id,因为它是组件所必需的 prop。

引用:https://react-bootstrap.github.io/components.html#btn-dropdowns-props

为组件提供一个 id。它会正常工作。

<SplitButton bsStyle={title.toLowerCase()} title={title} key={i} id={exampleId}>
<MenuItem eventKey="1">Action</MenuItem>
<MenuItem eventKey="2">Another action</MenuItem>
<MenuItem eventKey="3">Something else here</MenuItem>
<MenuItem divider />
<MenuItem eventKey="4">Separated link</MenuItem>
</SplitButton>

关于javascript - propType 失败 : The prop `id` is required to make `Dropdown` accessible for users of assistive technologies such as screen readers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40823716/

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