1.1.组件定义方式:
函数式:
function Welcome(){
return (
<h1>Hello React.js</h1>
)
}
ReactDOM.render( <Welcome name="Welcome" />, document.getELementById('root') );
类继承:
class Welcome extends React.Component{
render(){
return (<h1>Hello React.js</h1>);
}
}
ReactDOM.render( <Welcome name="Welcome" />, document.getELementById('root') );
React.createClass:
var Welcome = React.createClass({
render:function(){
return (<h1>Hello React.js</h1>);
}
})
ReactDOM.render( <Welcome name="Welcome" />, document.getELementById('root') );