reactjs - 选择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>;
解决方案
您可以简单地在 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
推荐阅读
- java - 导入枚举类时找不到符号错误
- webpack - terser-webpack-plugin 在另一台机器上生成不同的输出
- dictionary - 使用 Ansible 将嵌套字典展平为键/值对
- sql - 创建显示日期和日期之间的用户计数的视图
- html - 页脚的大小与其内容无关。(HTML、CSS)
- apache-spark - pyspark中的有效累积枢轴
- javascript - 我的按键事件可能有什么问题?
- r - 如何在R中订购日期?
- c# - 使用 count(*) 查询计算总数时出现错误,但出现“值不能为空参数名称数据表”的错误
- java - 我想在处置之前保存我在 jframe 上所做的更改