我试图将类名传递给react组件以更改其样式,但似乎无法正常工作:
class Pill extends React.Component {
  render() {
    return (
      <button className="pill {this.props.styleName}">{this.props.children}</button>
    );
  }
}
<Pill styleName="skill">Business</Pill>
我正在尝试通过传递具有相应样式的类的名称来更改药丸的样式。我是React的新手,所以也许我做的方式不正确。谢谢


借助React对字符串插值的支持,您可以执行以下操作: