ant design 1.7.8 a-select组件,在右侧增加搜索图标
时间: 2023-10-07 16:14:16 浏览: 41
要在 Ant Design 1.7.8 版本的 Select 组件中的右侧增加搜索图标,可以使用 Select 组件的 suffix 属性。具体的做法是,在 Select 组件中设置 suffix 属性的值为一个包含搜索图标的 JSX 元素,如下所示:
```
import { Select } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
const { Option } = Select;
function handleChange(value) {
console.log(`selected ${value}`);
}
<Select
showSearch
style={{ width: 200 }}
placeholder="Select a person"
optionFilterProp="children"
onChange={handleChange}
suffix={<SearchOutlined />}
>
<Option value="jack">Jack</Option>
<Option value="lucy">Lucy</Option>
<Option value="tom">Tom</Option>
</Select>
```
通过设置 suffix 属性的值为 `<SearchOutlined />`,就可以在 Select 组件的右侧增加搜索图标了。同时,也可以使用其他的 JSX 元素来替代搜索图标,以满足不同的需求。