如何清除AntDesign选择?

时间:2019-12-02 07:46:41

标签: javascript reactjs antd

我使用React Ant Design,我需要清除AntD select中的选定值。 不使用价值道具怎么办?

Example

2 个答案:

答案 0 :(得分:1)

您可以尝试在allowClear中使用道具Select

<Select
   mode="tags"
   style={{ width: "100%" }}
   onChange={handleChange}
   tokenSeparators={[","]}
   allowClear
>
  {children}
</Select>

enter image description here

答案 1 :(得分:0)

为您创建了stackblitz。以编程方式清除antd-select的值并不容易,但可以使用fireChange