【问题标题】:How to use props in react css?如何在反应 css 中使用道具?
【发布时间】:2019-11-06 15:37:22
【问题描述】:

下面是我的 React App 的部分代码:

<span 
  value={this.props.range}
  style={{width:"{this.props.range}px"}}
  className="range"
></span>

我想使用道具中的值并想设置为样式。 但我不知道如何设置它。

【问题讨论】:

标签: javascript css reactjs react-props


【解决方案1】:

试试这样的模板字符串:

<span 
  value={this.props.range}
  style={{width:`${this.props.range}px`}}
  className="range"
></span>

【讨论】:

    猜你喜欢
    • 2017-03-24
    • 1970-01-01
    • 2015-02-07
    • 1970-01-01
    • 2016-03-06
    • 1970-01-01
    • 2016-08-29
    • 2021-02-22
    • 1970-01-01
    相关资源
    最近更新 更多