更新时间:2023-12-03 10:51:16
您正在导入整个firebase
模块.仅导入auth
.以下对我有用:
You're importing the entire firebase
module. Only import auth
. The following works for me:
// Don't import the whole module, only `auth`.
import { auth } from 'firebase/app';
constructor(private readonly afAuth: AngularFireAuth) { }
signIn() {
this.afAuth.auth.setPersistence(auth.Auth.Persistence.LOCAL).then(() => {
// Now sign-in using your chosen method.
return this.afAuth.auth.signInAnonymously();
}).catch((error) => {
// Handle errors here.
let errorCode = error.code;
let errorMessage = error.message;
console.error(errorCode, errorMessage);
});
}