IE11等待承诺结果
我该如何等待Promise/Script.onload执行即可执行:.then(),.catch(),等待/异步和回调IE11。与CPP上的睡眠(100)相当的东西。如果我做一个循环'while(loadflag == false);'并检查标志是否已更改,浏览器悬挂并停止响应。我想取得类似的成就:
ScriptLoad(script);
functionFromLoadedScript();
但是我无法做到这一点...请帮助解决这个问题
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有状态标志,则可以使用
setInterval
对状态进行轮询。您还可以在IE中加载
Promise
Polyfill库,因此您可以使用然后使用
/catch
。async
/不需要等待
。承诺可以通过链接做同样的事情。如果您真的想使用async
/等待
可以使用typescript
到目标es5
。typescript
可以转移 async /等待
使用Promise> Promise> Promise
将在IE中运行。为此,您必须定位ES5,并且必须在IE中加载Promise
polyfill库。If you have a status flag you could use
setInterval
to poll the status.https://developer.mozilla.org/en-US/docs/Web/API/setInterval
You could also load a
Promise
polyfill library in IE so you can usethen
/catch
.async
/await
are not required. Promises can do the same with chaining. If you really want to useasync
/await
you can useTypeScript
to targetES5
.TypeScript
can transpileasync
/await
to the equivalent code usingPromise
that will run in IE. For this to work you must target ES5 and you must load aPromise
polyfill library in IE.不幸的是,这是不可能的。
Unfortunately, this is not possible.