我目前有这个简单的反应应用程序,我不能让这些onchange事件为我的生命开火.
var BlogForm = React.createClass({
getInitialState: function() {
return {
title: '',
content: ''
};
},
changeTitle: function(event) {
var text = event.target.value;
console.log(text);
this.setState({
title: event.target.value
});
},
changeContent: function(event) {
this.setState({
content: event.target.value
});
},
addBlog: function(ev) {
console.log("hit hit");
},
render: function() {
return (
<form onSubmit={this.addBlog(this)}>
<div>
<label htmlFor='picure'>Picture</label>
<div><input type='file' id='picture' value={this.state.picture} /></div>
</div>
<div>
<input className="form-control" type='text' id='content' value={this.state.title} onChange={this.changeTitle} placeholder='Title' />
</div>
<div>
<input className="form-control" type='text' id='content' value={this.state.content} onChange={this.changeContent} placeholder='Content' />
</div>
<div> …Run Code Online (Sandbox Code Playgroud)