首页 > 解决方案 > 选择ant design react组件禁用文本输入

问题描述

我有这段代码,我想禁用 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>;

标签: reactjsantd

解决方案


您可以简单地在 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


推荐阅读