我遇到错误
RepositoryFactory.getRepository(DeviceModelRepo.class)
我从发生此错误的地方粘贴了zone.js的一小部分
Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)
at Function.push../node_modules/zone.js/dist/zone.js.Zone.assertZonePatched (zone.js:58)
at new NgZone (core.js:24212)
at getNgZone (core.js:24925)
at PlatformRef.push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModuleFactory (core.js:24823)
at core.js:24867
at exceljs.min.js:3
at MutationObserver.n (exceljs.min.js:3)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runGuarded (zone.js:161)
at MutationObserver.<anonymous> (zone.js:144)
抛出以上错误。我确实在努力解决这个问题。
出现此错误
在我的项目中,我有一个任务是导出具有样式的Excel工作表。我找到了一个名为exceljs的软件包。包括这个之后,我开始收到此错误。
exceljs.js自述文件中的一些相关文档
function Zone(parent, zoneSpec) {
this._parent = parent;
this._name = zoneSpec ? zoneSpec.name || 'unnamed' : '<root>';
this._properties = zoneSpec && zoneSpec.properties || {};
this._zoneDelegate =
new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec);
}
Zone.assertZonePatched = function () {
if (global['Promise'] !== patches['ZoneAwarePromise']) {
throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' +
'has been overwritten.\n' +
'Most likely cause is that a Promise polyfill has been loaded ' +
'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' +
'If you must load one, do so before loading zone.js.)');
}
};
要使用ES5转换代码,请使用dist / es5路径。
## ES5 Imports
注意::ES5版本对许多不再使用的polyfill具有隐式依赖性 由exceljs明确添加。 您需要将“ core-js”和“ regenerator-runtime”添加到您的依赖项中, 在导入exceljs之前,在代码中包含以下要求:
const ExcelJS = require('exceljs/dist/es5');
浏览化
// polyfills required by exceljs
require('core-js/modules/es.promise');
require('core-js/modules/es.object.assign');
require('core-js/modules/es.object.keys');
require('regenerator-runtime/runtime');
// ...
const ExcelJS = require('exceljs/dist/es5');
我正在使用es6。所以我想念的是。请帮帮我。
角度版本详细信息。
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.js"></script>
<script src="exceljs.js"></script>
答案 0 :(得分:0)
到您提出问题时,您现在可能已经弄清楚了...从您的 polyfills.ts 中注释掉这一行
// import 'zone.js/dist/zone'; // Included with Angular CLI.