typescript类中的一个函数返回eval
。如何解包/产生该承诺中的值。
Promise<string>
答案 0 :(得分:4)
如何解包/产生该承诺中的值
您可以使用async
/ await
:https://basarat.gitbooks.io/typescript/content/docs/async-await.html
不要误以为你只是从异步转为同步,它只是.then
的包装:https://basarat.gitbooks.io/typescript/content/docs/async-await.html#generated-JavaScript
答案 1 :(得分:2)
试试这个
functionB(): string {
return this.functionA().then(value => ... );
}