的索引I有一個js片段,其產生一個錶行與JavaScript數組地圖功能如何確定的長度和當前項
TD S作爲如下
var cols = this.props.cols;
data = this.state.data
return data.map(function (item) {
var cells = cols.map(function (colData) {
console.log(colData);
return <td>{item[colData.key]}</td>;
});
return <tr key={item.Id }>{cells}</tr>;
});
我想確定最後一列,並想添加一個特定的按鈕td 如何獲取cols.map(函數(coldata)中的單元格長度,不確定是否能夠通過這種方法完成它
想進去cols.map的cells.length(函數( coldata) – Kalanamith
然後'cols.length'應該幫助.. – Rayon