【问题标题】:React select inline options反应选择内联选项
【发布时间】:2018-04-24 17:38:39
【问题描述】:

我正在使用 react-select,我想知道如何使用 optionRenderer 内联显示我的选项。见下图:

#react-select

【问题讨论】:

  • 你使用的是哪个版本的 react-select ?

标签: react-select


【解决方案1】:

您可以在标签选项中使用 JSX

const options = [
  { 
    label: <div className="label-item">ORA</div>, 
    value="ORA" 
  }, ....
]

然后修改 react-select 的类来自定义它(可能使用 styled-components)

import 'styled' from 'styled-component'
import 'select' from 'react-select'
const StyleSelect = styled(select).`
  .select {
    .select-control { ... } 
  }
`

就像普通的select一样使用StyleSelect

【讨论】:

    猜你喜欢
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-19
    • 2021-08-16
    • 2019-11-08
    相关资源
    最近更新 更多