首页 > react组件子元素的样式怎么设置?

react组件子元素的样式怎么设置?

var EzPanelComp = React.createClass({
            render : function(){
                return     <div className="ez-panel">
                            <div className="header">{this.props.title}</div>
                            <div className="content">
                                {this.props.children}
                            </div>
                        </div>;
            }
        });

有个题目:修改示例代码中EzPanelComp组件,为内容文字中的p元素应用样式类: .hz-indent。

新手入门,懵逼了,求大神给个提示


思路:
使用 顶层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

【热门文章】
【热门文章】