错误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以获取用户信息。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...