react 声明组件的方法
2018-07-10 本文已影响17人
蛮吉大人123
- function方式
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
- ES6的class方式
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}