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
         })
    }
     
     
     
  • 相关阅读:
    表单
    html 基础代码
    thread
    流的存入读取
    异常

    Android——多线程编程练习题
    Android——进度对话框
    安卓3个练习题
    Android—对话框
  • 原文地址:https://www.cnblogs.com/pikachuworld/p/11726310.html
Copyright © 2011-2022 走看看