The following is a demo in react syntax:
<div>
<select name="lesson" value={this.state.lesson} onChange={ this.handlerChange }>
<option value={1}>1阶段</option>
<option value={2}>2阶段</option>
<option value={3}>3阶段</option>
</select> --- { this.state.lesson }
</div>
<div>
<textarea name='note' value={ this.state.note } onChange = { this.handlerChange }></textarea>
</div>
state = {
lesson: 1,
note: '',
}
handlerChange = (event) => {
console.log(event.target.name)
this.setState({ [event.target.name]: event.target.value })
}
The above is achieved by defining the name attribute on the tag
The second method is the most common way I use in vue. Assuming that the event parameters are fixed and you want to expand the passed parameters, you can do this:
<div>
<select value={this.state.lesson} onChange={ (e)=>this.handlerChange(e,"lesson") }>
<option value={1}>1阶段</option>
<option value={2}>2阶段</option>
<option value={3}>3阶段</option>
</select> --- { this.state.lesson }
</div>
<div>
<textarea value={ this.state.note } onChange = {(e)=>this.handlerChange(e,"note") }></textarea>
</div>
handlerChange = (event,type) => {
console.log(type)
this.setState({ [type]: event.target.value })
}
The expression may not be very clear, but if you understand it, I believe it will be much more convenient for you in the project!