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:"双向数据绑定" } } 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它的值都没有发生变化不使用子组件的时候这样是没问题的,这个逻辑哪里有问题呢?
添加回答
举报
0/150
提交
取消