更新时间:2023-11-24 15:02:16
您可以执行以下操作:
this.client["pendingRequests"].forEach(request => {
request.abort();
});
我必须做["pendingRequests"]
,因为我正在使用TypeScript,并且数组似乎不在定义之内.
I am having to do ["pendingRequests"]
as I'm using TypeScript and the array does not seem to be within the definition.
注意:我还针对每个自动完成功能使用了范围限定的HttpClient,因此,当它取消所有先前的请求时,不会意外取消该应用程序正在请求的其他内容.
Note: I am also using a scoped HttpClient per autocomplete, so that when it cancels all previous requests it will not accidentally cancel something else that the app is requesting.