我正在尝试将用户名添加到我的锚点标签的href
属性中。
我的代码如下:
var Name = React.createClass({
render: function() {
return (
<div>
<a href="www.example.com/"+ { this.props.username} +"" className="post-title">{this.props.name}</a><br />
</div>
);
}
});
但是,我的程序出现了一个错误,显示在 href 属性附近有未定义的标记 "+"。我认为这是因为我试图在渲染方法中添加它所导致的。那么,是否有其他方法可以解决这个问题呢?
谢谢。
http://www.example.com/{this.props.username}
而不是http://www.example.com/anyusername
。 - Swapnil Bhikule