import React, { Component } from 'react'import ReactDOM from 'react-dom'class App extends Component { constructor(props) { super(props); this.state = {
val:"React的双向数据绑定" } } change=(event)=>{ this.setState({val:event.target.value}) } render() {
return (
<div> <input type="text" value={this.state.val} onChange={this.change} /> {this.state.val} </div> ); }} ReactDOM.render(<App/>,window.root)/*
event 事件对象
event.target 事件源
利用了event.target这个事件源去更新react中的数据状态
*/