摘要: 在状态初始化时设定一个state{timer:null} 在componentDidMount方法中设置定时执行的方法 this.state.timer=setInterval(()=>{ //需要定时执行的方法 }, 5000) 在componentWillUnmount方法中要对定时器进行销毁 阅读全文
posted @ 2019-11-22 13:49 薄荷+猫 阅读(2383) 评论(0) 推荐(1) 编辑