只留给特别笨的自己,也是特别笨的方法,省的以后还是不会,再慢慢改进吧╮(╯▽╰)╭
var codeTime =60;
constructor(props) {
super(props);
// 初始状态
this.state= {
timerCount:codeTime,
timerTitle:''
};
}
this.interval=setInterval(() =>{
vartimer=this.state.timerCount-1
if(timer===0){
this.interval&&clearInterval(this.interval);
this.setState({
timerCount:codeTime,
timerTitle:'重新获取'
})
}else{
this.setState({
timerCount:timer,
})
}
},1000)
网友评论
clearInterval(this.interval);
}