react native 子組件向父組件傳值


父組件:
 
引入子組件:import CheckBox from  '../checkbox';
 
父子之間交互通信,接受子組件的值
fn(val){
this.setState({
roleType:val
});
}
 
//調用通信
<CheckBox data={this.state.roleType} isRow={styles.isRow} fn={this.fn.bind(this)}/>
 
子組件:
其中fn里面傳遞的值為要傳遞給父組件的值
onPress={()=>{
this.props.fn(this.state.data)
}}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM