簡體   English   中英

帶有角度 6 導入問題的 Firebase?

[英]Firebase with angular 6 imports problems?

我正在使用 google firebase 創建用戶注冊系統,我正在關注本教程:

用戶注冊系統

筆記

:我正在使用這個版本“firebase”:“^5.5.6”,

當我運行我的應用程序時,出現以下錯誤:

ERROR in src/app/login/login.component.ts(2,10): error TS2305: Module '"C:/Users/jelly/projects/profile/node_modules/angularfire2/index"' has no exported member 'AngularFire'.
src/app/login/login.component.ts(3,28): error TS2305: Module '"C:/Users/jelly/projects/profile/node_modules/angularfire2/firestore/index"' has no exported member 'AuthProviders'.
src/app/login/login.component.ts(3,43): error TS2305: Module '"C:/Users/jelly/projects/profile/node_modules/angularfire2/firestore/index"' has no exported member 'AuthMethods'.

這是 app.modul.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule, JsonpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { UserProfileComponent } from './user-profile/user-profile.component';
import {HttpClientModule} from '@angular/common/http';
import { UserService } from './service/user.service';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { MomentModule } from 'ngx-moment';
import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';
import { LoginComponent } from './login/login.component';
import { EmailComponent } from './email/email.component';
import { SignupComponent } from './signup/signup.component';
import { AngularFireAuthModule } from 'angularfire2/auth';
import { AngularFireDatabaseModule} from 'angularfire2/database';



const firebaseConfig = {
  apiKey: '',
  authDomain: '',
  databaseURL: '',
  projectId: '',
  storageBucket: '',
  messagingSenderId: ''
};


@NgModule({
  declarations: [
    AppComponent,
    UserProfileComponent,
    LoginComponent,
    EmailComponent,
    SignupComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgbModule,
    BrowserModule,
    MomentModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    AngularFireAuthModule,
    BrowserModule,
    AngularFirestoreModule,
    AngularFireModule.initializeApp(firebaseConfig),
    AngularFireDatabaseModule,
    HttpModule,
    FormsModule,
    HttpClientModule,
    ReactiveFormsModule,
    RouterModule,
    AppRoutingModule,
  ],
  providers: [UserService],
  bootstrap: [AppComponent]
})
export class AppModule { }

這里是登錄組件其他組件就只是 empyt

import { Component, OnInit } from '@angular/core';
import { AngularFire, } from 'angularfire2';
import { AngularFirestore, AuthProviders, AuthMethods, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore';
import { Router } from '@angular/router';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {

  // declare empyt array to hold error data
  error: any;

  constructor(public af: AngularFire, private router: Router) {

  // fucntion to check user authentication
    this.af.auth.subscribe(auth => {
      if (auth) {
        this.router.navigateByUrl('/members');
      }
    });
   }

  // function to login in facebook
  loginFb() {
    this.af.auth.login({
      provider: AuthProviders.Facebook,
      method: AuthMethods.Popup,
    }).then(
      (success) => {
        this.router.navigate(['/members']);
    }).catch(
      (err) => {
        this.error = this.error;
      });
  }

    // function to login with google
    loginGoogle() {
      this.af.auth.login({
        provider: AuthProviders.Facebook,
        method: AuthMethods.Popup,
      }).then(
        (success) => {
          this.router.navigate(['/members']);
      }).catch(
        (err) => {
          this.error = this.error;
        });
    }

  ngOnInit() {
  }

}

我已經在堆棧溢出中使用了幾乎所有的解決方案,但沒有任何效果,我現在要放棄了,我沒有看到任何關於這個的好的文檔讓傻瓜了解到底發生了什么:(

我需要更改什么才能擺脫此錯誤? 請幫忙

教程是從 2017 年 1 月 17 日開始的,如果你運行npm install angularfire2 firebase --save你將安裝最新版本的 firebase,這不是一個教程所基於的,看這里是關於這個問題的類似帖子

因此,您必須降級用於此項目的 firebase 版本或升級導入,以便它們指向正確的文件,您可以在其中找到所需的類

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM