问题
I am getting issue while using angular 6 and IE 11, app is working fine in chrome & another browser but in internet explorer, i am getting this
ERROR Error: Uncaught (in promise): Error: Loading chunk default~app-xxxxx~eb5ba6d4 failed. (missing: http://localhost:4200/default~app-xxxx.js) Error: Loading chunk default~app-xxxx~eb5ba6d4 failed. (missing: http://localhost:4200/default~app-xxxx~eb5ba6d4.js)
Project details
Angular CLI: 6.2.3 Node: 8.12.0 OS: win32 x64 Angular: ...
Package Version
@angular-devkit/architect 0.8.3 @angular-devkit/core 0.8.3 @angular-devkit/schematics 0.8.3 @schematics/angular 0.8.3 @schematics/update 0.8.3 rxjs 6.2.2 typescript 2.9.2
My app routing is
const routes: Routes = [
{
path: '',
loadChildren: 'app/content/pages/pages.module#PagesModule'
},
{
path: 'layout',
loadChildren: 'app/content/layout/layout.module#LayoutModule',
},
{
path: '**',
redirectTo: ''
}
];
回答1:
I think you need to add some polyfills. If you open the src/polyfills.ts
file, you need to uncomment these imports:
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';
EDIT:
There might be more polyfils listed below this list, as mentioned by @Arikael in the comments, that you might want to uncomment as well.
回答2:
After investing some hours finally found my solutions Issue about promise((t,n) => ,
- At first, open the src/polyfills.ts file, and uncomment
/** IE9, IE10 and IE11 requires all of the following polyfills. **/ // import 'core-js/es6/symbol'; // import 'core-js/es6/object'; // import 'core-js/es6/function'; // import 'core-js/es6/parse-int'; // import 'core-js/es6/parse-float'; // import 'core-js/es6/number'; // import 'core-js/es6/math'; // import 'core-js/es6/string'; // import 'core-js/es6/date'; // import 'core-js/es6/array'; // import 'core-js/es6/regexp'; // import 'core-js/es6/map'; // import 'core-js/es6/weak-map'; // import 'core-js/es6/set';
=> lambda expression does not support in IE so we can replace with code function() instead of this expression.
Install some packages
npm install --save web-animations-js
npm install --save classlist.js
Then i was found promise issue from one of the npm package (fuctbase64/index.js)
module.exports = function (event) {
return new Promise((resolve, reject) => {
let reader = new FileReader();
let files = event.target.files;
let len = files.length;
if (len > 1) {
reject(new DOMException("Only one file can be uploaded at a time"));
} else {
reader.onerror = () => {
reader.abort();
reject(new DOMException("Problem parsing input file."));
};
let file = files[0]
reader.onload = (evt) => {
const uint = new Uint8Array(evt.target.result);
let bytes = [];
uint.map(byte => {
bytes.push(byte.toString(16));
});
const hex = bytes.join('').toUpperCase();
let base64 = reader.result.split(',')[1];
file.base64 = base64;
file.binaryFileType = getMimetype(hex);
resolve(file);
};
reader.readAsDataURL(file);
}
});
}
Replace code with
module.exports = function (event) {
return new Promise(function(resolve, reject) {
let reader = new FileReader();
let files = event.target.files;
let len = files.length;
if (len > 1) {
reject(new DOMException("Only one file can be uploaded at a time"));
} else {
reader.onerror = function() {
reader.abort();
reject(new DOMException("Problem parsing input file."));
};
let file = files[0]
reader.onload = function(evt){
const uint = new Uint8Array(evt.target.result);
let bytes = [];
uint.map(function(byte) {
bytes.push(byte.toString(16));
});
const hex = bytes.join('').toUpperCase();
let base64 = reader.result.split(',')[1];
file.base64 = base64;
file.binaryFileType = getMimetype(hex);
resolve(file);
};
reader.readAsDataURL(file);
}
});
}
回答3:
You have to add meta tag.
<meta http-equiv="X-UA-Compatible" content="IE=edge" >
回答4:
Can you check the steps from this? this was the issue with IE
Angular CLI applications require a few more steps in order to support Internet Explorer.
回答5:
I am new at angular. I have faced an error about "loading chunk xyz module failed" in Internet Explorer. I had tried lots of things but no solution. Finally I changed adding order of "declarations" array and "imports" array in NgModule definition. I mean defining "declarations" before "imports" in NgModule() solved my problem.
@NgModule({
declarations: [SomeComponent],
imports: [
FormsModule,
ReactiveFormsModule,
CommonModule,
MaterialModule,
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: translateHttpLoaderFactory,
deps: [HttpClient]
}
})
]
})
来源:https://stackoverflow.com/questions/55180018/internet-explorer-angular-6-error-error-uncaught-in-promise-error-loading