React学习笔记(五)之父子组件传递参数

父传子

通过属性,父组件向子组件传递参数。

this.state.list.map((item,index)=>{
    <todoItem content={item} />
}

子组件通过props(属性)来接收到父组件的参数

class todoItem extends React.Component{
    render(){
        return(
            <div>{this.props.content}</div>
        )
    }
}

子传父

猜你喜欢

转载自blog.csdn.net/qq_33338352/article/details/106186818