the*_*tto 17 javascript reactjs react-jsx
// This Javascript <a> tag generates correctly
React.createElement('a', {href:"mailto:"+this.props.email}, this.props.email)
Run Code Online (Sandbox Code Playgroud)
但是,我正在努力在JSX中重新创建它
<a href="mailto: {this.props.email}">{this.props.email}</a>
// => <a href="mailto: {this.props.email}"></a>
Run Code Online (Sandbox Code Playgroud)
href标记认为它{this.props.email}
是一个字符串而不是动态输入值{this.props.email}
.关于我去哪里的任何想法都不对?
Pat*_*ick 37
它返回一个字符串,因为您将其分配给字符串.
您需要将其设置为动态属性,该属性包含其开头的字符串
<a href={"mailto:" + this.props.email}>email</a>
归档时间: |
|
查看次数: |
30114 次 |
最近记录: |