互联网浏览器Angular 6 ERROR错误:未捕获(承诺):错误:正在加载块 [英] Internet explorer & Angular 6 ERROR Error: Uncaught (in promise): Error: Loading chunk
问题描述
在使用angular 6和IE 11时出现问题,应用在chrome&另一个浏览器,但是在Internet Explorer中,我得到了这个
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
错误错误:未捕获(承诺):错误:正在加载块 默认〜app-xxxxx〜eb5ba6d4 失败的. (缺少: http://localhost:4200/default〜app-xxxx.js ) 错误: 加载块default〜app-xxxx〜eb5ba6d4失败. (丢失的: http://localhost:4200/default〜app-xxxx〜eb5ba6d4.js )
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)
项目详细信息
Angular CLI:6.2.3 节点:8.12.0 操作系统:win32 x64 角度: ...
Angular CLI: 6.2.3 Node: 8.12.0 OS: win32 x64 Angular: ...
@ angular-devkit/architect 0.8.3 @ angular-devkit/核心0.8.3 @ angular-devkit/schematics 0.8.3 @ schematics/角度0.8.3 @ schematics/更新0.8.3 rxjs 6.2.2 打字稿2.9.2
@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
我的应用路由为
const routes: Routes = [
{
path: '',
loadChildren: 'app/content/pages/pages.module#PagesModule'
},
{
path: 'layout',
loadChildren: 'app/content/layout/layout.module#LayoutModule',
},
{
path: '**',
redirectTo: ''
}
];
推荐答案
经过几个小时的投资,终于找到了我的解决方案 关于promise((t,n)=>,
After investing some hours finally found my solutions Issue about promise((t,n) => ,
- 首先,打开src/polyfills.ts文件,然后取消注释
/** 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';
=> IE中不支持lambda表达式,因此我们可以用代码function()代替此表达式.
=> lambda expression does not support in IE so we can replace with code function() instead of this expression.
-
安装一些软件包
Install some packages
npm install-保存web-animations-js
npm install --save web-animations-js
npm install-保存classlist.js
npm install --save classlist.js
然后我从一个npm软件包(fuctbase64/index.js)中发现了Promise问题
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);
}
});
}
用
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);
}
});
}
这篇关于互联网浏览器Angular 6 ERROR错误:未捕获(承诺):错误:正在加载块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!