typescript - 使用异步等待获取数据加载
问题描述
我尝试使用 async-await 在 typescript vue 3 上获取数据,但是当数据未定义时(或在函数调用工作之前),此函数已经控制台
private async exportDataOrder() {
await this.getDataExport() // function call
let data = await this.controller.exportOrderData // result function
if (data) {
console.log(data, 'dari vue')
console.log('waiting')
}
}
解决方案
假设这exportOrderData
是一个异步函数,您忘记了()
实际调用您的函数。
let data = await this.controller.exportOrderData()
推荐阅读
- android - Android Q 不推荐使用 DownloadManager.addCompletedDownload()
- java - 如何使用 maven/dependency 在 Java 中访问/导入 oracle.security.jps.service
- keras - 在自动编码器中可视化卷积层
- azure - 如何将卷(Azure 文件共享)挂载到 Azure(容器的 Web 应用程序)上基于 bitnami 的 docker 映像?
- spring - 从 JWT 令牌获取 UserInfo 信息并在 Spring Boot OAuth2 自动配置上仅使用 JWK 验证
- android - consumeAsync 返回错误代码 5:开发人员错误
- excel - 复制和粘贴忽略主表的循环
- java-8 - 如何使用流获取父 POJO 类字段值
- google-cloud-platform - Update Display Name of Organization Resource in GCP
- python - 从命令行python脚本运行时tkinter不工作