1
我試圖將.map中的一個元素移到onClick函數,以便我可以將它傳遞給redux,但我不知道如何繼續。這是我的代碼如何將數據從.map傳輸到帶有onClick的href元素的功能
const Lists = lists.map((list, index) =>
<li key={index}> {list.name} <a href="#" onClick={this.listInfo.bind(this)}>Learn More</a> </li>);
這是功能提前
listInfo(event){
event.preventDefault();
var el = list.name //this is where I want to save that value;
console.log(el)
}
感謝
謝謝,這個作品 – OunknownO
請接受,如果適合你 – Zinc
對不起,我不能接受它立即 – OunknownO