小编Jos*_*hez的帖子

如何摆脱函数中的异步?

假设我有这个代码:

const myFunction = async => {
  const result = await foobar()
}

const foobar = async () => {
  const result = {}
  result.foo = await foo()
  result.bar = await bar()
  return result
}
Run Code Online (Sandbox Code Playgroud)

我想要这个:

const myFunction = () => {
  const result = foobar()
}
Run Code Online (Sandbox Code Playgroud)

我尝试像这样包装foobar :

const foobar = async () => {
  return (async () => {
    const result = {}
    result.foo = await foo()
    result.bar = await bar()
    return result
  })()
}
Run Code Online (Sandbox Code Playgroud)

但这仍然返回一个承诺

我不能在 …

javascript async-await nightwatch.js

5
推荐指数
1
解决办法
1748
查看次数

如何使用C++ Builder打开带有按钮的新表单?

我有一个Form1和Form2的程序.如何从form1单击按钮打开form2?

c++builder

1
推荐指数
2
解决办法
2万
查看次数