3 回答
TA贡献1982条经验 获得超2个赞
您需要添加组件,如下所示,仅出于演示目的添加一个选项,您可以按照自己的方式设置样式。
即使您可以使用可重用的组件来生成标签,因为标签接受一个节点。
我希望这能解决问题。
{
value: "page_visited",
label: (
<>
<span style={{ paddingRight: "5px" }}>Page Visited</span>
<FontAwesomeIcon icon="info" title={"Page Visited Option"} />
</>
)
},
整个代码
import React, { Component } from "react";
import ReactDOM from "react-dom";
import Select from "react-select";
import { library } from "@fortawesome/fontawesome-svg-core";
import { fab } from "@fortawesome/free-brands-svg-icons";
import { faInfo, faCoffee } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
library.add(fab, faInfo, faCoffee);
const websiteFilterFiedsOptions = [
{ value: "", label: "Search and select website activity" },
{
value: "page_visited",
label: (
<>
<span style={{ paddingRight: "5px" }}>Page Visited</span>
<FontAwesomeIcon icon="info" title={"Page Visited Option"} />
</>
)
},
{ value: "form_submitted", label: "Form Submitted" }
];
export default class Website extends Component {
constructor(props) {
super(props);
this.state = {
selectedFilter: ""
};
}
filterSelectedData = function(data) {};
render() {
return (
<div className="form-group">
<h6 className="website_filter">
<b>Filters</b>
</h6>
<div className="location-search field-width filed_width_custom">
<Select
value={this.state.selectedFilter}
onChange={e => this.filterSelectedData(e)}
options={websiteFilterFiedsOptions}
placeholder="Search and select website activity"
/>
</div>
</div>
);
}
}
const rootElement = document.getElementById("root");
ReactDOM.render(<Website />, rootElement);
TA贡献1856条经验 获得超5个赞
添加回答
举报