Antd select +自定义标签不适用于labelInValue

时间:2020-09-03 12:08:26

标签: antd

自定义标签不适用于labelInValue。

<div className="App">
  <Select value="apple" style={{ width: "100%" }}>
    {items.map((item) => (
      <Option value={item.value} label={item.label}>
        <div>
          <span style={{ background: "#10899e" }}>{item.label}TEST</span>{" "}
          {item.label}
        </div>
      </Option>
    ))}
  </Select>
  <Select
    labelInValue
    optionLabelProp={"label"}
    value={items.find(({ value }) => value === "apple")}
    style={{ width: "100%" }}
  >
    {items.map((item) => (
      <Option value={item.value} label={item.label}>
        <div>
          <span style={{ background: "#10899e" }}>{item.label}TEST</span>{" "}
          {item.label}
        </div>
      </Option>
    ))}
  </Select>
</div>

查看示例

https://codesandbox.io/s/charming-river-jdrdf?fontsize=14&hidenavigation=1&theme=dark

0 个答案:

没有答案