我想在输入中执行两个事件,如何连续调用它们或者我应该如何声明方法?我尝试了以下方式,但它给我一个错误,你能给我一些建议吗?
我的条目
<input style={styles.input} placeholder='Introduce tu nombre' type='text'
name={this.state.nombre} onChange={this.bChange, this.hChange}>
和事件
hChange(e) {const name = e.target.value;
this.setState({input:name});
this.props.cambioNombre(name); }
bChange(e) {const letras= e.target.value;
if(letras >= 4) {
this.setState({habilitado:false});
} else if (!this.state.habilitado) {
this.setState({habilitado:true});
} }
如果使用React.js,你可以这样做:
在vanilla JavaScript的情况下,您可以这样做:
onChange
将with中的功能分开,;
以便在完成事件时执行它们。