我在Internet Explorer中遇到了这个具体错误(“未捕获(承诺):[对象未定义]”),该错误似乎与polyfill有关。当在加载少量JavaScript文件的同时创建新的Promise时,似乎正在发生这种情况。我没有在其他浏览器中看到此问题,这使我认为这可能是一个polyfills问题。
以下是我的polyfills.js文件中的内容:
import 'zone.js/dist/zone';
import 'core-js/es7/object';
import 'core-js/es7/array';
以下是创建Promise的代码:
export const loadFile = () => {
return new Promise((resolve, reject) => {
loadScript('scripts/jquery-1.11.1.min.js').then(
() => {
loadScript((window as any).someUrl).then(
() => { resolve(); },
() => { reject(); },
);
},
() => {
reject();
}
);
});
};
不确定我缺少什么。这是我在开发人员工具中看到的错误
"Error: Uncaught (in promise): [object Undefined]
at Z (url/polyfills.4ac2578f6ae1e7f25aa5.js:1:13528)
at Z (url/polyfills.4ac2578f6ae1e7f25aa5.js:1:13092)
at Anonymous function
(url/polyfills.4ac2578f6ae1e7f25aa5.js:1:14322)
at e.prototype.invokeTask
(url/polyfills.4ac2578f6ae1e7f25aa5.js:1:8178)
at onInvokeTask (httpurl/main.0460452a7b0bcdb247fe.js:1:62633)
at e.prototype.invokeTask
(url/polyfills.4ac2578f6ae1e7f25aa5.js:1:8178)
at t.prototype.runTask
(url/polyfills.4ac2578f6ae1e7f25aa5.js:1:3458)
at g (url/polyfills.4ac2578f6ae1e7f25aa5.js:1:10562)
at t.invokeTask (url/polyfills.4ac2578f6ae1e7f25aa5.js:1:9414)
at m (url/polyfills.4ac2578f6ae1e7f25aa5.js:1:22829)"