# day2-react-communication **Repository Path**: zhang-pingyang/day2-react-communication ## Basic Information - **Project Name**: day2-react-communication - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-15 - **Last Updated**: 2020-12-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## react 中的通信 * 父传子 ```javascript //在子组件标签上传递一个属性,在子组件内通过this.props接受 class xxx extends React.Component { constructor(props){ super(props) //这里调用super方法,继承父组件的属性,props必加 this.state={ title:this.props.title } } ``` * 子传父 //在子组件标签上绑定一个方法,该方法要定义在父组件内,然后再子组件内调用该方法,给父组件传值 this.prop.方法(参数)