在我的Angular 8.0项目开发模式下,使用angular CLI。
它仅适用于Chrome,一切正常,但不适用于Firefox / Edge / IE11。
在Firefox / Edge中打开项目时,我停留在登录页面上,键入帐户/密码,然后单击登录,但是F12中什么都没有发生,没有错误或消息。
当我在IE11中打开项目时,只有白色页面,也没有错误或消息。
请帮助我怎么做
我发现有人说在polyfills中导入es6-slim或reflict.js,但这也不起作用。
我的package.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)
);
}
我发现问题与下面的拦截器有关, console.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)
)
)
答案 0 :(得分:0)
您需要编辑browserlist文件,并在此配置文件中允许IE11。如果使用Angular CLI项目,则会自动创建此文件。只需打开文件,文件包含如下-
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.
按照上述说明,只需从最后一行删除not关键字,然后尝试。
答案 1 :(得分:0)
对不起, 我发现发生了什么事 我的错, 与浏览器或角度无关 我在本地存储区出错,导致这种情况发生, 感谢您的帮助,可以关闭此问题。