我有以下内容:
<MenuItem
primaryText={currentUserProfile.displayName || currentUserProfile.email}
onTouchTap={this.handleTouchTap}
leftIcon={<DropDownArrow color={textColor}/>}
rightIcon={<img src="{currentUserProfile.displayName}" alt="Me" />}
style={{color: textColor}}
/>
rightIcon 无法工作,因为它已经在 {} 中 --- 如何让变量在 {} 中工作?
最佳答案
您将 URL 指定为 "{currentUserProfile.displayName}"
作为字符串文字。您应该使用 rightIcon={<img src={currentUserProfile.displayName} alt="Me" />}
编辑: 注意你的引号。
关于javascript - 在 React 中,如何在变量中包含变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44748516/