使用https://react-select.com/home,我一直在尝试以下想法的不同变化:
const hex = 'f2bc';
const char = unescape('%u' + hex);
<Select
defaultValue={ label: char, value: 'some-value'}
...={...}/>
这是上述尝试的结果:
![输入图像描述](https://istack.dev59.com/YY6jm.webp)
使用https://react-select.com/home,我一直在尝试以下想法的不同变化:
const hex = 'f2bc';
const char = unescape('%u' + hex);
<Select
defaultValue={ label: char, value: 'some-value'}
...={...}/>
react-select
非常灵活,可以传递PropTypes.node
作为label
选项。
font-awesome
图标可以与className一起使用应用于HTMLSpan元素,例如:
const labelWithIcon = <span className="fas fa-stroopwafel" />
<Select defaultValue={{ label: labelWithIcon, value: 'some-value' }} />
react-select
一起。我认为这不是原始问题的一部分。 - Oluwafemi Suleconst options = [
{ value: "text", label: <FontAwesomeIcon icon={faFileAlt} /> },
{ value: "image", label: <FontAwesomeIcon icon={faFileImage} /> },
{ value: "video", label: <FontAwesomeIcon icon={faFileVideo} /> }
];
<Select placeholder="Text" options={options} />