<div>
<table>
<thead>
<tr>
<th>編號(hào)</th>
<th>姓名</th>
<th>年齡</th>
</tr>
</thead>
<tbody?id="listinfo">
</tbody>
</table>
</div> var?arr?=?[
{
id:'1001'
,name:'張三'
,age:'20'
}
,{
id:'1002'
,name:'李四'
,age:'21'
}
];
var?Ids??=?React.createClass({
render:function(){
return(
<tr>{
React.Children.map(this.props.children,function(child){
return?<td>{child}</td>;
})
}
</tr>
);
}
});?
ReactDOM.render(
<Ids>
<span>{arr[0].id}</span>
<span>{arr[0].name}</span>
<span>{arr[0].age}</span>
</Ids>,
document.getElementById('listinfo')
);
</script>問題: 這樣只顯示第一個(gè)對(duì)象的屬性, 如何將所有對(duì)象的屬性都遍歷出來?
react循環(huán)遍歷
荼酒
2016-05-30 11:18:55