Angular 角度/火基应用程序约10秒,直到浏览器中显示更改
在使用firebase身份验证时,我遇到了一个奇怪的问题 我能够在一个简单的应用程序中重现这个问题,该应用程序应该显示用户是否能够使用firebase auth(谷歌帐户)登录 问题是,结果消息会在控制台中打印,但不会立即在浏览器中显示。大约10秒钟后,屏幕刷新并显示错误消息 我怎样才能避免这种延误 app.component.tsAngular 角度/火基应用程序约10秒,直到浏览器中显示更改,angular,firebase,firebase-authentication,Angular,Firebase,Firebase Authentication,在使用firebase身份验证时,我遇到了一个奇怪的问题 我能够在一个简单的应用程序中重现这个问题,该应用程序应该显示用户是否能够使用firebase auth(谷歌帐户)登录 问题是,结果消息会在控制台中打印,但不会立即在浏览器中显示。大约10秒钟后,屏幕刷新并显示错误消息 我怎样才能避免这种延误 app.component.ts import {Component} from '@angular/core'; import {AuthService} from './auth-service
import {Component} from '@angular/core';
import {AuthService} from './auth-service.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
msg: string;
constructor(private authService: AuthService) {}
login() {
this.authService.loginWithGoogle()
.then(() => {
console.log('success');
this.msg = 'success';
}
)
.catch((err) => {
console.log('error:'+ err);
this.msg = err.message;
});
}
}
app.compontent.html
<div>Error is: {{msg}}</div>
<button (click)="login()">
Login
</button>
您可以在此处查看问题:
使用任何谷歌帐户登录
更新:这只发生在chrome上。使用Chrome59是因为缓存。调试时禁用缓存 这是因为缓存。调试时禁用缓存
import {AngularFireAuth} from 'angularfire2/auth';
import * as firebase from 'firebase/app';
@Injectable()
export class AuthService {
constructor(private afAuth: AngularFireAuth) {
}
loginWithGoogle() {
return this.afAuth.auth.signInWithPopup(new
firebase.auth.GoogleAuthProvider());
}
}