5

我正在为 React 使用 Ant 设计组件。我想修复多选输入字段的大小,以便将选定的值放入同一行而不像默认行为那样换行:

https://ant.design/components/select/#components-select-demo-multiple

我需要将值排列在同一行中。

我可以通过覆盖样式来修复输入字段的大小

.ant-select-selection--multiple:before, .ant-select-selection--multiple:after  {
display: inline !important;  }

但是当我选择几个值时,它们就在 inputr 字段之外。

4

2 回答 2

4

您可以指定 maxTagCount

 <Select
  mode="multiple"
  maxTagCount={1}
>
  // here is rendering of the Opitons
</Select>
于 2020-08-27T14:00:22.083 回答
2

最后我通过添加这个 css 样式选项找到了一个解决方案:

.ant-select-selection--multiple
{
   white-space: nowrap;
   height: 30px;
   overflow: auto
}

因此,div 看起来像一个输入文本字段,当内容落地时,div 字段的右侧会出现一个滚动条。

于 2017-06-15T07:31:33.200 回答