private timer;//定时器
constructor(private service:ReconTaskService,private messageService: MessageService,private router: Router) {
this.timer = setInterval(() => {//设置定时刷新事件,每隔1分钟刷新
this.list();
}, 60000)
}
//销毁
ngOnDestroy() {
if (this.timer) {
clearInterval(this.timer);
}
}
参看了:https://blog.csdn.net/happyniceyq/article/details/78887932