【问题标题】:semantic ui react dropdown selected item icon语义 ui 反应下拉所选项目图标
【发布时间】:2019-04-10 18:54:23
【问题描述】:

我正在尝试使用语义 ui 和 React 创建一个下拉/选择,并且我希望它在所选项目上显示复选标记。 我当前的代码是:

 groupSelector() {
    let groups = Object.keys(this.state.data).map((val, index) => {
      return {
        text: val,
        value: index,
        image: (
          <span style={{ color: this.state.data[val].Color }}>&#9733;</span>
        )
      };
    });
    return (
      <Dropdown
        placeholder="choose group"
        id="dropdown"
        selection
        fluid
        options={groups}
        onChange={(e, { value }) => {
          this.setGroupToShow(value, e);
        }}
      />
    );
  }

帮助任何人?

【问题讨论】:

    标签: reactjs icons dropdown semantic-ui


    【解决方案1】:

    我会尝试使用 css 来实现这一点。为这个下拉列表添加一些自定义样式到 item.selected 类。在这些自定义样式中,您可以添加一个带有复选标记的伪元素。

    【讨论】:

    • i added "icon:null" to all groups, and when selected (before re-render) i set the icon of selected index to
    猜你喜欢
    • 2020-12-05
    • 2019-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多