[英]Adding parameter in anchor tag in react.js
我正在嘗試在我的錨標記的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>
);
}
});
但是,我收到一條錯誤消息,說undefined token +
在該 href 屬性附近。 我認為這是因為我試圖在渲染方法中添加它。 那么,還有其他方法嗎?
謝謝..
刪除+
。 它應該是:
<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.