【发布时间】:2017-10-24 14:59:22
【问题描述】:
我是新来的反应。我需要帮助在我的项目的 react js 中禁用一个按钮 5 秒钟,然后重新启用它。
这是我的代码,
constructor (props) {
super(props);
this.onLaunchClicked = this.onLaunchClicked.bind(this);
this.state = {
isButtonDisabled: false
}
}
onLaunchClicked (event) {
event.preventDefault();
this.setState({
isButtonDisabled: true
});
return this.props.onLaunchClicked();
}
render () {
return (
<div className="client-playtest-state">
<button className="btn bg-success" onClick={this.onLaunchClicked}
disabled={this.state.isButtonDisabled}>LAUNCH</button>
</div>
);
}
【问题讨论】:
-
分享到目前为止所做的事情。
-
您可以超时 5 秒。请分享你所拥有的代码示例。我们不是来为你编码的。
-
对不起,我错过了添加代码,
标签: reactjs