此错误意味着GoogleAuthProvider类未被正确导入或未包含在项目中。为了解决这个问题,需要确保GoogleAuthProvider类被正确导入并在项目中可用。
以下是可能的
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '../environments/environment';
@NgModule({
imports: [
BrowserModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireAuthModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}
import { GoogleAuthProvider } from "firebase/auth";
import { Injectable } from "@angular/core";
import { AngularFireAuth } from "@angular/fire/auth";
import { GoogleAuthProvider } from "firebase/auth";
@Injectable()
export class AuthService {
constructor(private afAuth: AngularFireAuth) {}
signInWithGoogle() {
const provider = new GoogleAuthProvider();
return this.afAuth.signInWithPopup(provider);
}
}
这些解决方法中的一个或多个可能会解决“GoogleAuthProvider does not exist”的错误。