taro父、子组件通信


父page

let personInfo = {
            mobile: this.state.mobile,
            email: this.state.email
 }
传入自组件参数   personData={personInfo} 
<PersonInfo   personData={personInfo}  onHandleChange={this.handleInputChange.bind(this)}/>
 
 
子page
自组件传到父组件 this.props.onHandleChange()比如你想传一个布尔值就this.props.onHandleChange(false)
 handleMobileChange(e){
        console.log('----handleMailChange-----', this.state.mobile)
        this.setState({
            email: e.target.value
        },() => {
            this.props.onHandleChange({
                mobile: this.state.mobile,
                email: this.state.email
            })
        })
    }
 
<Input type='text' placeholder='请输入手机号' value={personData.mobile} onChange={this.handleMobileChange.bind(this)} />
 
父page接收值(拿个手机举例子)
 
handleInputChange(value){
     console.log('===888==我要接收==mobile===', value, '===email===')
     this.setState({
         mobile: value.mobile,
         email: value.email
     })
}
 
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM