How can I make the onKeyPress
event work in ReactJS?
(如何让onKeyPress
事件在ReactJS中工作?)
It should alert when enter (keyCode=13)
is pressed.(当按下enter (keyCode=13)
时它应该enter (keyCode=13)
警报。)
var Test = React.createClass({
add: function(event){
if(event.keyCode == 13){
alert('Adding....');
}
},
render: function(){
return(
<div>
<input type="text" id="one" onKeyPress={this.add} />
</div>
);
}
});
React.render(<Test />, document.body);
ask by user544079 translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…