Kaivosukeltajajokeyrhyme提出了一个问题:How can I synchronously determine a JavaScript Promise's state?,或许与您遇到的问题类似。
回答者Benjamin Gruenbaum给出了该问题的处理方式:
No such synchronous inspection API exists for native JavaScript promises. It is impossible to do this with native promises. The specification does not specify such a method.
Userland libraries can do this, and if you're targeting a specific engine (like v8) and have access to platform code (that is, you can write code in core) then you can use specific tools (like private symbols) to achieve this. That's super specific though and not in userland.
希望本文对你有帮助,欢迎支持JavaScript中文网
来源:JavaScript中文网 ,转载请注明来源 本文地址:https://www.javascriptcn.com/post/13245