0
render() {
return (
<table className="table table-condensed table-hover">
<thead>
<col width="30"/>
<col width="50"/>
<col width="240"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="53"/>
<tr>
<th></th>
<th>QTY</th>
<th>Supplier</th>
<th>WETA</th>
<th>CETA</th>
<th>Chase</th>
<th>Tracking</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<col width="30"/>
<col width="50"/>
<col width="240"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="53"/>
{this.props.rows.forEach((row) => {
<tr>
<td>{row.id}</td>
</tr>
}
)}
<tr>
<td>A</td>
<td>24</td>
<td>JC Electronics</td>
<td>24/06/2016</td>
<td>26/06/2016</td>
<td>27/06/2016</td>
<td>25/06/2016</td>
<td>S</td>
</tr>
</tbody>
</table>
)
}
但沒有出來的那個循環的,這是我第一次嘗試這個,所以我會做錯事,但它是什麼?
我似乎做已經做到了:
render() {
var rowData = this.props.rows.map((row) => {
return (
<tr>
<td>{row.id}</td>
<td>{row.id}</td>
<td>{row.id}</td>
<td>{row.id}</td>
<td>{row.id}</td>
<td>{row.id}</td>
<td>{row.id}</td>
<td>{row.id}</td>
</tr>
)
});
return (
<table className="table table-condensed table-hover">
<thead>
<col width="30"/>
<col width="50"/>
<col width="240"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="53"/>
<tr>
<th></th>
<th>QTY</th>
<th>Supplier</th>
<th>WETA</th>
<th>CETA</th>
<th>Chase</th>
<th>Tracking</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<col width="30"/>
<col width="50"/>
<col width="240"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="80"/>
<col width="53"/>
{rowData}
<tr>
<td>A</td>
<td>24</td>
<td>JC Electronics</td>
<td>24/06/2016</td>
<td>26/06/2016</td>
<td>27/06/2016</td>
<td>25/06/2016</td>
<td>S</td>
</tr>
</tbody>
</table>
)
}
你想使用'map',而不是'forEach' – Bergi
@Bergi我仍然沒有輸出。 – imperium2335
你確定在你的props.rows裏有什麼東西嗎?嘗試在返回之前插入一個「console.log(this.props.rows)」來查看包含哪些行 – rakwaht