0
粘貼下面我摘錄作爲參考:傳遞值動態地href屬性
getInitialState: function()
{
return {
repoLinks: [
"/reports/interactive/CustomersReport",
"/reports/interactive/MapReport"
]
}
render: function(){
var repoLinks = this.state.repoLinks;
repoLinks = repoLinks.map(function(item, index)
{
var home = "http://myurl";
var reportLink = {item};
var link = home + reportLink.item;
console.log(link);
// HyperLink1.NavigateUrl = link;
// return(<a href='"link"'>Report </a>);
// return(<a href="'link'">Report </a>);
// <a href="link" class='dynamicLink'>Report </a>;
/*
<div>
<a onclick="javascript:GoToUrl();"> Reports </a>
<script type="text/javascript">
function GoToUrl()
{return("http://myurl" + {item});}
</script>
</div>
*/
/*
<div>
<a onclick="return Try();"> Reports </a>
<script type="text/javascript">
function Try()
{return(link_final);}
</script>
</div>
*/
return(<a href= "link">Report </a>);
});
}
我需要做的是通過變量的「鏈接」到HREF。鏈接包含最終的URL。我已經嘗試了一些我在上面評論中顯示的解決方案。
基本上我想在第一個循環中通過它「http://myurl+/reports/interactive/CustomersReport」,在第二個循環中通過「http://myurl+/reports/interactive/MapReport」。
請幫我理解我在哪裏可能會出錯。 謝謝!