原例:
handleForm(e){
e.preventDefault();
console.log(this.refs['title'].value)
const newQuestion = {
title: this.refs['title'].value,
voteCount: 0,
}
}
<form ref="addQuestionForm" onSubmit={this.handleForm.bind(this)}>
<div className="form-group">
<input ref="title" />
</div>
</form>
在获取 ref 时,this 并不能确定他的指向,所以要在调用回调函数handleForm时写上 bind(this) , 用以确定指向