<div> <table> <thead> <tr> <th>编号</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>
问题: 这样只显示第一个对象的属性, 如何将所有对象的属性都遍历出来?