javascript - react组件子元素的样式怎么设置?
大家讲道理
大家讲道理 2017-04-10 17:15:21
0
1
392
var EzPanelComp = React.createClass({ render : function(){ return 

{this.props.title}

{this.props.children}

; } });

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

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

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all (1)
迷茫

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

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!