20161024 版本中的发行说明显示了 Promises 的 ES3 polyfill,但是当我使用此版本编译并在 IE11 中进行测试时,我在控制台中收到一条错误消息,表明不支持 Promise.all():
TypeError: Object doesn't support property or method 'all'
(我在 gulp 任务定义中使用了 rewrite_polyfills: 'true'
。)
如果我添加这些控制台输出:
console.log( 'Promise: ' + Promise );
console.log( 'Promise.all: ' + Promise.all );
我在 IE11 中得到这个:
Promise: function c(b){this.b=0;this.o=void 0;this.a=[];var c=this.i();try{b(c.resolve,c.reject)}catch(p){c.reject(p)}}
Promise.all: undefined
这在 Chrome 中(按预期工作):
Promise: function Promise() { [native code] }
Promise.all: function all() { [native code] }
all() 方法不是 polyfill 的一部分吗?
最佳答案
是 - Polyfill 包含 Promise.all 定义:https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/js/es6/promise.js#L507-L548
关于javascript - Promises polyfill 是否在 Google Closure Compiler 20161024 中包含 all()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40391887/