【发布时间】:2017-11-23 09:45:01
【问题描述】:
在下面粘贴我的 sn-p 作为参考:
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。我已经尝试了一些我在上面的 cmets 中展示的解决方案。
基本上我想在第一个循环中传递“http://myurl+/reports/interactive/CustomersReport”,在第二个循环中传递“http://myurl+/reports/interactive/MapReport”。
请帮助我了解我可能在哪里出错。 谢谢!
【问题讨论】:
标签: javascript html reactjs variables href