【问题标题】:Firebase Authentication(Goggle) in AngularAngular 中的 Firebase 身份验证(护目镜)
【发布时间】:2020-07-30 20:54:49
【问题描述】:

我正在处理 firebase 身份验证,收到此错误:

“AngularFireAuth”类型上不存在属性“auth”。

return this.afAuth.auth.signInWithEmailAndPassword(email, password)
      .then((result) => {
        this.ngZone.run(() => {
          this.router.navigate(['dashboard']);

auth 出现错误

【问题讨论】:

    标签: angularjs firebase-authentication angularfire2


    【解决方案1】:

    @Abdullah,auth 不是AngularFireAuth 的一部分,它是firebase 包的一部分。

    如下更新你的代码

    import * as firebase from 'firebase/app';
    

    npm install firebase --save dependency if not installed

    return firebase.auth().signInWithEmailAndPassword(email, password)
          .then((result) => {
            this.ngZone.run(() => {
              this.router.navigate(['dashboard']);
    

    【讨论】:

    • 我试过这个但还是不行,我已经更新了代码但仍然得到错误代码 return this.afAuth.firebase.auth.signInWithEmailAndPassword(email, password)
    【解决方案2】:

    我正在处理我认为的同一个项目。我发现从 "@angular/fire": "^6.0.0" AngularFireAuth 已经删除了 auth 属性。

    改用此代码:

    this.afAuth.signInWithEmailAndPassword(email, password)
    

    来源:https://github.com/angular/angularfire/issues/2409#issuecomment-615993136

    【讨论】:

    猜你喜欢
    • 2020-05-20
    • 2021-05-29
    • 2017-02-24
    • 2018-04-15
    • 2020-06-01
    • 2019-02-26
    • 1970-01-01
    • 2017-01-22
    • 2020-08-13
    相关资源
    最近更新 更多