- 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>;
}
}
本文标题:react 声明组件的方法
本文链接:https://www.haomeiwen.com/subject/pfboyftx.html
网友评论