react-select:有没有办法删除右侧的按钮来展开列表,至少在异步模式下? [英] react-select: Is there a way to remove the button on the right that expand the list, at least in async mode?

查看:56
本文介绍了react-select:有没有办法删除右侧的按钮来展开列表,至少在异步模式下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AsyncSelect 并且我想隐藏右侧的向下箭头按钮,该按钮显示选项列表.

I am using AsyncSelect and I would like to hide the arrow-down button on the right, the one that display the list of options.

当有默认选项时才有意义.但就我而言,我没有,所以那个按钮在我的情况下毫无意义.

It can make sense when there are default options. But it my case I have none, so that button makes no sense it my situation.

当处于 async 模式并且没有默认选项时,有没有办法删除/隐藏它?

Is there a way to remove/hide it, when in async mode and there no default options ?

下面是代码

<AsyncSelect
  placeholder="Search ..."
  cacheOptions
  defaultOptions={false}
  value={this.state.currentValue} // Default to null
  loadOptions={this.fetchOptions}
  onChange={...}
  isClearable
/>

另外,是否可以禁用组件在获得焦点时显示空列表的事实,并且仅在输入至少一个字符时才显示匹配的选项.

Also, is it possible to disable the fact that the component display an empty list when it get the focus, and only display matched options when at least one character is entered.

很抱歉问二合一.

提前致谢.

推荐答案

我们可以通过包含 DropdownIndicator: () =>组件属性中的 null.

更新:正如@shlgug 和@nickornotto 建议通过包含IndicatorSeparator:() => 来删除分隔符.空

Update:As @shlgug and @nickornotto suggested remove separator by including IndicatorSeparator:() => null

<Select
   components={{ DropdownIndicator:() => null, IndicatorSeparator:() => null }}
 />

这篇关于react-select:有没有办法删除右侧的按钮来展开列表,至少在异步模式下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆