首页 > 解决方案 > 需要帮助使用 Angular Firebase 进行错误处理

问题描述

我正在制作一个聊天服务应用程序,但我遇到了一个我无法找到解决方案的错误。我的代码是:

import { Component, OnInit } from '@angular/core';
import { AuthService } from '../services/auth.service';
import { Observable } from 'rxjs';
import * as firebase from 'firebase/app';
import {User} from '@firebase/auth-types';

@Component({
  selector: 'app-navbar',
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.css']
})

export class NavbarComponent implements OnInit {
 user!: Observable<firebase.User>;
  userEmail!: string;

  constructor(private authService: AuthService) { }

  ngOnInit(): void {
  this.authService.authUser();
    this.user.subscribe(user => {
      if (user) {
        this.userEmail = user.email;
      }
    });
  }

  logout() {
    this.authService.logout();
  }
}

我得到的错误是:

命名空间 '"C:/Users/steve/met-chat/node_modules/firebase/index"' 没有导出成员 'User'.ts(2694)

我已确保已将 angular 和 firebase 更新到最新版本。如果有人可以提供帮助,我将不胜感激。

标签: javascriptangularfirebasefirebase-authentication

解决方案


推荐阅读