标签:pre component efault cto class const reac span default
import React from ‘react‘; import B from ‘./B‘; class A extends React.Component{ state = { msg:‘我来自于A组件‘ } isClick=(value)=> { this.setState({ msg: value }) } render() { return ( <div> 我是A组件: <hr /> <B msg={this.state.msg} myClick={this.isClick}/> </div> ) } } export default A;
import React from ‘react‘; class B extends React.Component{ constructor(props) { super(props) } render() { return ( <div> <h2>我是B组件:{this.props.msg}</h2> <button onClick={() => this.props.myClick(‘我来源于B组件‘)}>按钮</button> </div> ) } } export default B;
标签:pre component efault cto class const reac span default
原文地址:https://www.cnblogs.com/xuyan1/p/9757752.html