在React中,如何在变量中包含变量?

时间:2017-06-25 16:49:16

标签: javascript reactjs

我有以下内容:

      <MenuItem
        primaryText={currentUserProfile.displayName || currentUserProfile.email}
        onTouchTap={this.handleTouchTap}
        leftIcon={<DropDownArrow color={textColor}/>}
        rightIcon={<img src="{currentUserProfile.displayName}" alt="Me" />}
        style={{color: textColor}}
      />

rightIcon没有工作,因为它已经在{}中}如何让变量在{}内工作?

由于

1 个答案:

答案 0 :(得分:2)

您将网址指定为"{currentUserProfile.displayName}"作为字符串文字。您应该使用rightIcon={<img src={currentUserProfile.displayName} alt="Me" />}

编辑: 注意你的引号。