Reactjs 如果元素为';他是这样创造的?
如何将样式对象添加到此中 createElement的第二个参数是属性的散列,其中键是属性名,值是属性值。Reactjs 如果元素为';他是这样创造的?,reactjs,Reactjs,如何将样式对象添加到此中 createElement的第二个参数是属性的散列,其中键是属性名,值是属性值。style属性将样式名称的哈希值转换为值。例如: var MyElement = React.createClass({displayName: "FormatParagraph", render: function () { return ( React.createElement("p", null, this.props.paragrap
style
属性将样式名称的哈希值转换为值。例如:
var MyElement = React.createClass({displayName: "FormatParagraph",
render: function () {
return (
React.createElement("p", null, this.props.paragraph)
);
}
});
这样,您可以在id/class
中使用App.CSS
中指定的CSS
React.createElement("p", {style: {color: "red", backgroundColor: "blue"}}, this.props.paragraph)
React.createElement("p", {id : 'div1', className : 'news'}, this.props.paragraph)