react 声明组件的方法

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

https://reactjs.org/docs/components-and-props.html

上一篇 下一篇

猜你喜欢

热点阅读