繁体   English   中英

选择ant design react component禁用文本输入

[英]Select ant design react component disable text input

我有这段代码,我想禁止perevent用户输入文本aria输入仅从菜单工作中选择。

let sel = <Select
            showSearch
            readOnly
            style={{width: '40%', paddingRight: 40}}
            placeholder={this.props.title}
            dropdownStyle={{width: '38%', paddingRight:10}}
            onChange={this.SelectCity.bind(this)}
            {...inputProps}
            optionFilterProp="children"
        >
            {OptionSelect}
        </Select>;

您只需在Ant Design中禁用输入字段即可。

禁用使用

<Select
            showSearch
            disabled
            style={{width: '40%', paddingRight: 40}}
            placeholder={this.props.title}
            dropdownStyle={{width: '38%', paddingRight:10}}
            onChange={this.SelectCity.bind(this)}
            {...inputProps}
            optionFilterProp="children"
        >
            {OptionSelect}
        </Select>;

阅读官方文档了解更多信息, https://ant.design/components/input/#header

您可以检查官方文档antd select

此代码直接来自docs

   <Select defaultValue="lucy" style={{ width: 120 }} onChange={handleChange}>
      <Option value="jack">Jack</Option>
      <Option value="lucy">Lucy</Option>
      <Option value="disabled" disabled>Disabled</Option>
      <Option value="Yiminghe">yiminghe</Option>
    </Select>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM