import React from 'react'class Chinds extends React.Component{ render(){ return <div> <input value={this.props.dataValue} onChange={this.props.dataChange.bind(this)}/> <p>{this.props.dataValue}</p> </div> }}class Parent extends React.Component{ constructor (props){ super(props); this.state = { value:"雙向數(shù)據(jù)綁定" } } handleChange (event){ this.setState({value:event.target.value}) } render(){ var value = this.state.value; return <div> <Chinds dataValue={value} dataChange={this.handleChange}/> </div> }}export default Parent;無論我怎么操作input它的值都沒有發(fā)生變化不使用子組件的時候這樣是沒問題的,這個邏輯哪里有問題呢?
React 通過 子組件 進行雙向數(shù)據(jù)綁定的問題
慕容708150
2018-10-16 09:57:34