//dom
<div onKeyDown={this.keyCodeChange}>
<input id='input1 ref={(input) =>{this.input1 = input}} />
<input id='input2 ref={(input) =>{this.input2 = input}} />
<div id='buttonid'>登录</div>
</div>
js
keyCodeChange= (e) =>{
// 兼容FF和IE和Opera
let theEvent = e || window.event;
let code = theEvent.keyCode || theEvent.which || theEvent.charCode;
let Id = e.target.id;
if (code === 13) {
//回车执行查询
switch (Id) {
case 'input1' :
this.input2.focus();
break;
case 'input2' :
document.getElementById("buttonid").click();
break;
}
}
};