【发布时间】:2025-12-25 18:05:11
【问题描述】:
我试图在当前区域之外调整脚本:
async ngAfterViewInit(): Promise<void> {
this.ngZone.runOutsideAngular(() => {
await this.run();
});
}
async run() { // TODO }
我收到此错误:
'await' expressions are only allowed within async functions and at the top levels of modules.ts
【问题讨论】:
-
这能回答你的问题吗? Syntax for an async arrow function
标签: angular typescript asynchronous async-await zone.js