react 组件里使用定时器时得注意清除定时器,否则组件在卸载的时候,定时器还在运行。定时器开启和清除的地方
componentDidMount(){ this.timeID = setTimeout(function( console.log(222) ){},200) } componentWillUnmount(){ clearTimeout(this.timeID); }
Last updated 5 years ago
Was this helpful?