//子组件
class Childen extends React.Component {
render(porps) {
return (
<div>
{/*直接利用props触发事件*/}
<input onInput={this.props.changeInp} />
</div>
)
}
}
//子 性能比前者要高 class Childen extends React.Component{ changeInpp = (e) => {
//这里需从子组件获取event对象 并作为形参传过去 this.props.changName(e.target.value) } render(){ return( <p> <input type="text" onInput={this.changeInpp}/> </p> ) } }
//父类只需要接收数据并赋值就可以了
原文:https://www.cnblogs.com/zqxi/p/12108073.html