React 60s倒计时

前端之家收集整理的这篇文章主要介绍了React 60s倒计时前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
this.state = {
    btnText: 获取验证码‘,timer: 5,discodeBtn: false,clearInterval: false
}
let siv = setInterval(() => {
    this.setState({ timer: (timer--),btnText: timer,discodeBtn: true },() => {
        if (timer === 0) {
            clearInterval(siv);
            this.setState({ btnText: ‘重新发送‘,discodeBtn: false })
        }
    });
},1000);

猜你在找的React相关文章