Javascript ReactJs StyledComponents

Javascript ReactJs StyledComponents,javascript,reactjs,Javascript,Reactjs,我想使用一个属性返回样式化按钮。我正在寻找类似的东西: const Button = styled.button` /* Adapt the colors based on primary prop */ background: ${props => props.primary ? 'palevioletred' : 'white'}; color: ${props => props.primary ? 'white' : 'palevioletred'}; font

我想使用一个属性返回样式化按钮。我正在寻找类似的东西:

const Button = styled.button`
 /* Adapt the colors based on primary prop */
  background: ${props => props.primary ? 'palevioletred' : 'white'};
  color: ${props => props.primary ? 'white' : 'palevioletred'};

  font-size: 1em;
  margin: 1em;
  padding: 0.25em 1em;
  border: 2px solid palevioletred;
  border-radius: 3px;
`;

export default Button;  

不幸的是,我有两个以上的道具,我需要基于它们返回样式化组件。

您可以始终将对象作为属性传递

<Button myStyle={ { color: color ... } } />

谢谢你的提示,我用这个函数来决定设置哪种颜色

     function getColor(props){
          if(props.btn==='red'){return 'red';}
      }    


     color: ${(props) => getColor(props)};

很乐意帮忙:)
     function getColor(props){
          if(props.btn==='red'){return 'red';}
      }    


     color: ${(props) => getColor(props)};