In JSX, how do you reference a value from props from inside a quoted attribute value?(在JSX中,如何从带引号的属性值中引用props值?)
props
<img className="image" src="images/{this.props.image}" />
<img class="image" src="images/{this.props.image}">
React(或JSX)不支持在属性值内部进行变量插值,但是您可以将任何JS表达式放在花括号中作为整个属性值,因此这适用于:
<img className="image" src={"images/" + this.props.image} />
1.4m articles
1.4m replys
5 comments
57.0k users