How to add style to React Element if it's created this way?

前端 未结 2 1243
天涯浪人
天涯浪人 2021-01-07 19:07
var MyElement = React.createClass({displayName: \"FormatParagraph\",
    render: function () {
        return (
            React.createElement(\"p\", null, this.pro         


        
2条回答
  •  长发绾君心
    2021-01-07 19:34

    The second parameter to createElement is a hash of attributes where the key is the attribute name and the value is the attribute value. The style attribute takes a hash of style names to values. So, for example:

    React.createElement("p", {style: {color: "red", backgroundColor: "blue"}}, this.props.paragraph)
    

提交回复
热议问题