react组件传参
react-组件间传参 父组件向子组件传参 父传子通过(props)属性向子组件的attr中传值 父组件 parent.js import React , { Component } from "react" ; import Child from "../child" ; export default class Parent extends Component { constructor ( props ) { super ( props ) ; this . state = { name : "zhangsan" , } ; } render ( ) { return ( < div > parent { /* 父组件通过props,向子组件attr属性把state中的值传给子组件 */ } < Child name = { this . state . name } / > < / div > ) ; } } 子组件Child.js import React , { Component } from "react" ; export default class Child extends Component { render ( ) { // 子组件通过props接受 let { name } = this . props ; return < div > 父组件传来的参数