You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在React中禁用AntD AutoComplete组件的拼写检查?

禁用Ant Design AutoComplete组件的拼写检查方法

Ant Design的AutoComplete组件基于原生input实现,默认会启用浏览器的拼写检查功能。要禁用它,你可以通过inputProps属性给内部的input元素传递spellcheck="false"原生属性:

修改后的代码示例:

<AutoComplete
  options={options}
  onSearch={handleSearch}
  onSelect={handleSelect}
  placeholder={placeholder}
  inputProps={{ spellcheck: false }}
/>

原理说明:

  • inputProps是AutoComplete提供的用于传递原生input属性的参数,传入该对象的属性会直接绑定到内部的input元素上。
  • 原生HTML的spellcheck属性设为false时,会关闭浏览器对该输入框的拼写检查提示。

内容的提问来源于stack exchange,提问作者shunshun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 02:14:51