我正在尝试构建一个从 PHP 脚本的输出数组动态生成的表。执行 componentWillMount 后,我得到以下输出。但我正在尝试使用这些数据(前 4 行是一行)并构建一个表。但我无法获得如何使用此数组数据并将其动态转换为表格。任何输入都受到高度赞赏。
2016-08-24 20:24:06
2016-08-24 20:24:06
test01
20
2016-08-19 08:14:25
2016-08-19 08:14:25
test02
10
componentWillMount: function () {
$.ajax({
type: "GET",
crossDomain: true,
url: "http://localhost:8080/myscript.php",
success: function(data){
alert(data);
this.setState({testRows: data});
}.bind(this),
error:function(data)
{
alert("Data sending failed");
}
});
},
return(
<tbody>
{this.state.testRows.map(function(row, i) {
return (
<tr key={i}>
{row.map(function(col, j) {
return <td key={j}>{col}</td>;
})}
</tr>
);
})}
</tbody>
)