弹性容器中的react选择

IT技术 javascript reactjs flexbox react-select
2021-05-13 17:10:12

如何让 react-select 尊重 flex 布局?以下没有任何工作。

 const Container = styled('div')`
   width: 100%;
   height: 100%;
   display: flex;
   flex-flow: row wrap;
   justify-content: space-around;
   align-items: baseline;
 `;

const selectStyles = {
  input: base => ({
    minWidth: 200,
    flex: 1,

<Container>
<Select
  style={{ flex: 1 }}
  styles={selectStyles}
1个回答

为了让你的react-select组件灵活,你需要flex:1像这样在容器上应用props:

const styles = {
  container: base => ({
    ...base,
    flex: 1
  })
};

<Select styles={styles} />