如何禁用可创建的反应选择组件? [英] How do I disable a Creatable react-select component?
本文介绍了如何禁用可创建的反应选择组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道要用什么道具来禁用可创建的React-select组件,它只是缺少了吗?
I can't figure out what prop to use to disable a Creatable React-select component, is it just missing?
我尝试了常规的isDisabled道具,但未成功.
I tried the regular isDisabled prop but was unsuccessful.
<CreatableSelect
name="serviceOrders"
className="hide-options"
value={selectOptions()}
isDisabled={headerLock}
onChange={e => {
this.handleHeaderChange(
e,
'serviceOrders',
);
}}
placeholder="Type SO, then press enter..."
multi
/>
我想在特定情况下将其禁用.
I want to disable it for specific situations.
推荐答案
用于Select组件的 isDisabled
道具适用于 react-select v2 及更高版本.如果您使用的是 1.x.x 版本,请使用 disabled
道具禁用选择组件
The isDisabled
prop for Select components is applicable for react-select v2 and above. In case you are using a version 1.x.x please use the disabled
prop to disable the select component
render() {
return (
<CreatableSelect
isClearable
isDisabled
onChange={this.handleChange}
onInputChange={this.handleInputChange}
options={colourOptions}
/>
);
}
这篇关于如何禁用可创建的反应选择组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文