var EzPanelComp = React.createClass({
render : function(){
return <p className="ez-panel">
<p className="header">{this.props.title}</p>
<p className="content">
{this.props.children}
</p>
</p>;
}
});
有个题目:修改示例代码中EzPanelComp组件,为内容文字中的p元素应用样式类: .hz-indent。
新手入门,懵逼了,求大神给个提示
迷茫2017-04-10 17:17:21
思路:
使用 顶层API React.Children.map
React.Children.map(object children, function fn [, object context])
function 里面判断是否p元素,若是加上className=“hz-indent”
相关API官方文档: http://reactjs.cn/react/docs/top-level-api.html