父组件:
 
引入子组件: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)
}}

相关文章:

  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-23
  • 2022-03-09
  • 2022-12-23
  • 2021-04-13
  • 2022-12-23
  • 2021-10-28
相关资源
相似解决方案