Angular 只能在 chrome 中使用,而在 Firefox 中不起作用.边缘或 IE11



在我的 Angular 8.0 项目开发模式下,使用 angular CLI。

它仅适用于Chrome,一切都很好,但是在Firefox/Edge/IE11中不起作用。

当我在Firefox/Edge中打开项目时,我卡在登录页面上,我输入我的帐户/密码,然后单击登录,但随后没有任何反应,F12中没有错误或消息。

当我在IE11中打开项目时,只得到一个白页,也没有错误或消息。

请帮我怎么做,

我发现有人说在填充物中导入 es6-slim 或 reflict.js,但它也不起作用。

我的包.json

{
"name": "std-web",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.6",
"@angular/cdk": "~8.2.0",
"@angular/common": "~8.2.6",
"@angular/compiler": "~8.2.6",
"@angular/core": "~8.2.6",
"@angular/flex-layout": "^8.0.0-beta.27",
"@angular/forms": "^8.2.6",
"@angular/material": "^8.2.0",
"@angular/platform-browser": "~8.2.6",
"@angular/platform-browser-dynamic": "~8.2.6",
"@angular/router": "~8.2.6",
"@ngx-formly/bootstrap": "^5.4.2",
"@ngx-formly/core": "^5.4.2",
"@ngx-formly/material": "^5.4.2",
"bootstrap": "^4.3.1",
"hammerjs": "^2.0.8",
"ng-zorro-antd": "^8.3.0",
"rxjs": "~6.5.3",
"tslib": "^1.9.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.4",
"@angular/cli": "~8.3.4",
"@angular/compiler-cli": "~8.2.6",
"@angular/language-service": "~8.2.6",
"@types/jasmine": "~3.4.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~12.7.5",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~8.4.1",
"tslint": "~5.20.0",
"typescript": "3.5.3"
}
}

我的登录页面组件:

completeSetup(): void {
//console.log(data);
this.loginService.postAccountInfo(this.username, this.password)
.subscribe(res => { 
this.obj = res 
this.store.set(INIT_FLAG, true);
this.store.set(USERNAME, this.username);
this.store.set(AUTHTOKEN,this.obj.authToken);
console.log("login sucess");
this.router.navigateByUrl('main/sc/candidate');
},
(error) => {
this.checkAuth = true;
console.log(error);
});
}

我的登录服务:

postAccountInfo(username, paswword) {
//AuthInfo:AuthInfo;
return this.http.post("/um/login", {
observe: "response",
userName:username,
password:paswword,
groupId:"1234",
orgId:"ykdemo"
}).pipe(
catchError(this.handleError)
);
}

我发现问题出在我的拦截器上,如下所示, 控制台.log不会显示,但这在 Chrome 中工作正常,多么奇怪!

return next.handle(authReq)
.pipe( map((event: any) => {
this.handleData(event);
console.log("------") //console will not show
if (event instanceof HttpResponse && event.status === 200)
{   
return event;
}
}),
catchError(
(err: HttpErrorResponse) => this.handleData(err)
)
)

您需要编辑浏览器列表文件并允许在此配置文件中使用 IE11。如果您使用 Angular CLI 项目,则会自动创建此文件。只需打开文件,文件包含如下 -

> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.

按照上面的说明,只需从最后一行中删除 not 关键字,然后尝试。

对不起伙计们, 我发现了发生了什么, 是我的错, 与浏览器或角度无关, 我在本地存储中犯了一个错误,导致这种情况发生了, 感谢您的帮助,这个问题可以关闭。

相关内容

最新更新