如何解决错误TS2339:类型“ AngularFireAuth”上不存在属性“ auth”
所以我正在使用ionic4应用程序,但在try-catch块中的 auth 上出现错误。我尝试安装firebase软件包并添加 auth 导入,但似乎没有任何效果。可能是什么问题?
import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { Auth } from 'firebase';
@Injectable({
providedIn: 'root'
})
export class FirebaseAuthService {
auth: any[];
constructor(private angularFireAuth: AngularFireAuth) { }
async registerWithEmailPassword(email,password) {
try {
const result = await this.angularFireAuth.auth.createUserWithEmailAndPassword(email,password);
await this.angularFireAuth.auth.currentUser.sendEmailVerification();
return result;
} catch (error) {
throw new Error(error);
}
}
}
解决方法
使用最新的AngularFireAuth,您不再需要指定.auth。
您可以直接访问angularFireAuth.currentUser以获取用户信息。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。