如何在Select
选项中添加图标?我尝试了很多次,但都没有奏效:
<option value={0}>Item One</option>
<option value={1}>
<i class="fas fa-expand" />
Item two
</option>
完整示例代码:
class IconInSelect extends Component {
state = {
value: 0
};
handleChange = name => event => {
this.setState({ [name]: event.target.value });
};
render() {
const { value } = this.state;
const { classes } = this.props;
return (
<Select
autoWidth
native
value={value}
onChange={this.handleChange("value")}
name="value"
variant="filled"
classes={{
root: classes.selectEmpty,
select: classes.select
}}
>
<option value={0}>Item One</option>
<option value={1}>
<i class="fas fa-expand" />
Item two
</option>
<option value={2}>Item three</option>
</Select>
);
}
}