1.父組件向子組件傳遞數據:父組件綁定屬性值傳給子組件,子組件經過this.props()接受。this
2.子組件向父組件傳遞數據:子組件綁定一個方法,方法中經過this.props.父組件方法名(參數)傳遞給父組件,父組件經過該方法接受數據。ci
eg:console
子組件中傳遞數據:<button onClcik={()=>{this.change(value)}}></button>
change=(value)=>{
this.props.handleClick();
}
父組件中接收數據:
<Son handleClick={this.handleClick}></Son>
handleClick=(value)=>{
console.log(value)
}方法