//自动调整 export default class test1 extends Component{ constructor(props) { super(props); this.handleChange = this.handleChange.bind(this) this.state={ items:[], text:'' } } handleChange(e) { console.log(e.target.value) this.setState({ text: e.target.value }) }; render(){ return( <div> <h1>test:{this.state.text}</h1> {/*<listtest></listtest>*/} <form> <input id="name1" onChange={this.handleChange.bind(this)}/> <button id="button" onClick={this.handleSubmit.bind(this)}>add</button> </form> </div> ); } }