简体   繁体   English

Aurelia对话框和Typescript异步等待-找不到名称“等待”

[英]Aurelia dialog & Typescript async await - Cannot find name 'await'

I'm having problems using async await together with Aurelia Dialog . 我在与Aurelia Dialog一起使用异步等待时遇到问题。 Basically I want to send away a request when the dialog is closed and currently it gives me syntax error: 基本上,我想在关闭对话框时发送请求,当前它给我语法错误:

Cannot find name 'await' 找不到名称“ await”

If I move the request outside the .WhenClosed function I dont get any syntax error and I can fire away a request. 如果我将请求移到.WhenClosed函数之外,则不会收到任何语法错误,并且可以触发请求。

找不到名称“ await”

Why is it that I can't use async await inside the .whenClosed dialog and how can I overcome this? 为什么我无法在.whenClosed对话框中使用async等待,我该如何克服呢?

您传递给whenClosed的箭头函数必须是异步的

async response => {}

Maybe you should try to use 也许您应该尝试使用

.whenClose(async (response) => { let result_2 = await this.organisationService... })

to instead~ 代替〜

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM