gpt4 book ai didi

reactjs - 更改 "Select"的箭头图标

转载 作者:行者123 更新时间:2023-12-04 16:27:02 27 4
gpt4 key购买 nike

我想用 ant design ( https://ant.design/components/icon/ ) 提供的图标替换默认的下拉选择箭头,例如 DownCircleOutlined。是否可以?这是我目前的代码。我还没有任何风格,因为我不知道这种方法。

<Select>
<Option value="1">a</Option>
<Option value="2">b</Option>
<Option value="3">c</Option>
</Select>

最佳答案

使用 suffixIcon Select 上的 Prop 成分。

https://codesandbox.io/s/select-with-search-field-ant-design-demo-k217c?file=/index.js:0-679

像这样:

import React from 'react'
import ReactDOM from 'react-dom'
import 'antd/dist/antd.css'
import './index.css'
import { Select } from 'antd'
import { DownCircleTwoTone } from '@ant-design/icons'
const { Option } = Select

ReactDOM.render(
<Select
suffixIcon={<DownCircleTwoTone />}
showSearch
style={{ width: 200 }}
placeholder="Select a person"
optionFilterProp="children"
filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
>
<Option value="jack">Jack</Option>
<Option value="lucy">Lucy</Option>
<Option value="tom">Tom</Option>
</Select>,
document.getElementById('container')
)

关于reactjs - 更改 "Select"的箭头图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62057065/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com