【发布时间】:2019-07-02 07:52:26
【问题描述】:
我正在尝试将用于react-select 多选指示符的图标更改为字体很棒的图标,但它不起作用。知道为什么吗?
import React from "react";
import Select, { components } from "react-select";
import { colourOptions } from "./docs/data";
const Placeholder = props => {
return <components.Placeholder {...props} />;
};
const CaretDownIcon = () => {
return <i className="fas fa-caret-down" />;
};
const DropdownIndicator = props => {
return (
<components.DropdownIndicator {...props}>
<CaretDownIcon />
</components.DropdownIndicator>
);
};
export default () => (
<Select
closeMenuOnSelect={false}
components={{ Placeholder, DropdownIndicator }}
placeholder={"Choose"}
styles={{
placeholder: base => ({
...base,
fontSize: "1em",
color: colourOptions[2].color,
fontWeight: 400
})
}}
options={colourOptions}
/>
);
项目标签显示在 DOM 中,但我没有看到图标。
【问题讨论】:
-
您是否收到任何控制台错误?你看到
i标签出现在DOM中了吗? -
没有控制台错误,是的,我确实在 DOM 中看到了 item 标签。在上面发布图片。
标签: reactjs font-awesome react-select