Jac*_*eid 1 javascript event-handling javascript-events reactjs
给出以下代码:
var
React = require("react")
;
class ControlText extends React.Component {
constructor(props){
super(props);
this.state = {
value: ""
};
}
update() {
console.log(event);
this.setState({value: event.target.value});
}
render() {
console.log(this.state);
var value = this.state.value;
return <input type="text" value={value} onChange={this.update.bind(this)} />
}
}
module.exports = ControlText;
Run Code Online (Sandbox Code Playgroud)
每次我登录事件对象的update(),它返回一个对象target: null,并this.state.value更新从""到undefined.这段代码与Forms文档上的示例差异很小,为什么我似乎无法获得事件目标?