我在輸入字段中輸入過快時,我在瀏覽器中收到禁止錯誤 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調用期間阻止打字? –