zoukankan      html  css  js  c++  java
  • 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
         })
    }
     
     
     
  • 相关阅读:
    Foj1675数论
    JSTL与EL之间的千丝万缕
    2013多校联合2 I Warm up 2(hdu 4619)
    ios视图切换之push与present混用
    Ruby设计模式透析之 —— 适配器(Adapter)
    晓说智能指针shared_ptr为何可以实现跨模块分配和释放内存
    CSS的力量
    MySQL-select 1;
    MySQL数据库-语言简介
    Eclipse开发工具提交代码
  • 原文地址:https://www.cnblogs.com/pikachuworld/p/11726310.html
Copyright © 2011-2022 走看看