private timer
创建定时器
componentWillMount = async () => {
this.saveFormData();
}
saveFormData = () => {
this.timer = setInterval (() => {
this.save(); // 保存方法
}, 300000);
}
//删除组件时清除定时器
componentWillUnmount = () => {
clearInterval(this.timer);
}