父组件:
import React, { Component } from 'react';
import Child from './chlid';
class parent extends Component{
constructor(props) {
父组件改变子组件数据react?super(props);
this.state = {
txt0:"默认值0",
txt1:"默认值1"
}
}
react 父组件调用子组件方法、componentDidMount(){
}
parToson(){
this.setState({
txt0:"哈哈哈哈"
})
react兄弟组件传值、}
sonToPar(e){
this.setState({
txt1:e
})
}
react父子组件数双向传递。render(){
const style={
paddingLeft:"150px"
}
return(
传值给子组件
父子组件传值,)
}
}
子组件:
import React, { Component } from 'react';
class child extends Component{
react this,constructor(props) {
super(props);
this.state = {
msg:"啦啦啦啦"
}
}
react类组件,componentDidMount(){
}
render(){
return(
this.props.getsonToPar(this.state.msg)}>传值给父组件
)
react 组件。}
}
export default child;
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态