React组件二

<script type="text/babel">
<!-- this.props.children表示读取组件的所有子节点-->
var Zu=React.createClass({
render:function(){
return (
<ol>
{
React.Children.map(this.props.children,function(children){
return <li>{children}</li>;
})
}
</ol>
);
}
});

ReactDOM.render(
<Zu>
<span>AAAA</span>
<span>CCCCC</span>
</Zu>,
document.body
);
</script>

 

 

结果:1.AAAA

         2.CCCCC

posted @ 2016-06-15 16:36  闹闹猪  阅读(124)  评论(0编辑  收藏  举报