class App extends React.Component { constructor(props){ // 必須要傳遞參數(shù) super(props) this.state = { text: this.props.text } } render() { return ( // render不用傳props <div>{this.props.children}</div> ) }}constructor和render內(nèi)部this都指向組件實(shí)例,只要constructor內(nèi)部要讀取props就要寫明這個參數(shù),但是render不用,為什么呢?
render為什么不用傳參
人到中年有點(diǎn)甜
2018-10-12 14:15:13