-1
我有以下的vb.net代碼,我必須轉換成陣營:對於內含有循環鏈接呈現陣營
For i As Integer = 0 To List.Count - 1
MyList.AppendFormat("<li><a href=""some_url/page?id={0}""><i class=""fa fa-cloud""></i> {1}</a></li>", List(i).ListId, List(i).ListLocationName)
Next
到目前爲止,我做到了這一點代碼:
render() {
return (
<div>
{
<ul className="this-nav">
{this.props.list.map((value, index)=> <li><a href={"some_url/page?id=" + index}></a></li>)
}
</ul>
}
</div>
);
}
是它一個更好的方法來做到這一點?我在控制檯中得到了以下消息:
數組或迭代器中的每個子元素都應該有一個唯一的「key」屬性。 檢查MyList的渲染方法。
一兩件事,在地圖的回調函數,你有「價值」作爲參數,但它從來沒有使用過,是故意的嗎? –
檢查此答案[當需要在反應中](https://stackoverflow.com/questions/43904825/what-do-curly-braces-mean-in-jsx-react)和[** React DOC ** ](https://facebook.github.io/react/docs/introducing-jsx.html#embedding-expressions-in-jsx)瞭解如何在JSX中放置表達式。 –
[React JSX內部循環]的可能重複(https://stackoverflow.com/questions/22876978/loop-inside-react-jsx) –