1.var Bacon =React.createClass({
render:function(){
<div>
{rhis.props.title}
</div>
}
});
ReactDOM.render(
<div>
<Bacon title="hello" />
</div>,document.getElementById("#container")
)
2.注意样式的写法。事件
var Comment =React.createClass({
edit:function(){
alert("hello");
}
render:function(){
return (
<div><button className="button-primary" onClick={this.edit}></div>
)
}
})
获得子元素内容:{this.props.children}
<Bacon>这是子元素内容</Bacon>
3.state
var CheckBox = React.createClass({
getInitialState:function(){
return {check:true
},handleClick:function(){
this.setState({checked:!this.state.checked
});
},
render:function(){
}
}
})
网友评论