一、父?jìng)髯?/p>
1.將子組件引入父組件中 并在需要的位置嵌入
例如
import User from '../user';
jsx: <User />
-
在嵌入的組件上綁定自定義屬性
例如:
<User yh="1512A" msg="今天真熱啊" />
子組件如何接收 (this.props)
例如:<div>
用戶組件內(nèi)容---{ this.props.yh }---{this.props.msg}
</div>
react生命周期鉤子componentWillMount:組件首次渲染之前調(diào)用
componentDidMount:在首次真實(shí)的DOM渲染后調(diào)用(僅此一次)或請(qǐng)求外部接口數(shù)據(jù)時(shí)使用
componentWillUnmount:組件卸載后