首页 > 解决方案 > 弹性容器中的反应选择

问题描述

如何让 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}

标签: javascriptreactjsflexboxreact-select

解决方案


要使您的react-select组件具有弹性,您需要flex:1在容器上应用道具,如下所示:

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

<Select styles={styles} />

推荐阅读