[英]Adding parameter in anchor tag in react.js
I am trying to add a username in my anchor tag's href
property.我正在尝试在我的锚标记的
href
属性中添加用户名。 My Code is,我的代码是,
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>
);
}
});
But, I am getting an error saying undefined token +
near that href property.但是,我收到一条错误消息,说
undefined token +
在该 href 属性附近。 I think this is due to I am trying to add it in render method.我认为这是因为我试图在渲染方法中添加它。 So, is there any other approach?
那么,还有其他方法吗?
Thank you..谢谢..
Remove the +
.删除
+
。 It should be:它应该是:
<a href={"www.example.com/" + this.props.username} ...
另一种方法是:
<a href={`https://www.example.com/${this.props.username1}`}>link</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.