我想返回状态并将其值存储在变量s中。请帮忙一下,谢谢。
这是我的代码:
这是我的代码:
let s = setTimeout( ()=>{
this.matchService.getMatches().subscribe(ms => {
this.matches = ms;
let match = this.matches.find(match => match.id == id);
let status = match.status;
if(status == 'closed' || status == 'live') {
this.status.name = status;
}
return status;
});
},9000);
}
setTimeout()
函数确实会返回一个值,这个值是计时器本身的标识符。但是你不能从回调函数中返回任何东西,这没有意义。 - PointysetTimeout()
会立即返回;周围的代码不会等待计时器。 - Pointy