我在输入字段中输入过快时,我在浏览器中收到禁止错误 403。我使用阵营的js与节点,并在后端快递。在输入字段中输入快速时出现禁止错误
以下是我的代码,容纳输入。
import React, {Component, PropTypes} from 'react';
export default class SearchBox extends Component {
constructor(props) {
super(props);
this.state = {
name: "",
typing :false,
typingTimeOut :0,
};
this.changeName=this.changeName.bind(this);
this.sendtoParent=this.sendtoParent.bind(this);
}
changeName(event) {
const self=this;
if(self.state.typingTimeOut)
{
clearTimeout(typingTimeOut);
}
self.setState({
name: event.target.value,
typing:false,
typing: setTimeout(function(){
self.sendtoParent(self.state.name)},1000)
});
}
sendtoParent(){
this.props.searching(this.state.name,"true");
}
render() {
return (
<div >
<input
style={styles}
id="SearchBox"
type="text"
placeholder='Enter the name'
onChange={this.changeName}
/>
</div>
);
}
}
我叫去,后来给了我从Github上搜索API所需的JSON父。当我通常类型,但是它给出了快速打字的403错误我的代码是完美的工作。
有什么用'打字:FALSE'?你想在API调用期间阻止打字? –