【问题标题】:AngularFire2: you are using the development build of the firebase SDKAngularFire2:您正在使用 firebase SDK 的开发版本
【发布时间】:2018-11-01 09:19:04
【问题描述】:

所以我使用官方文档来设置和安装 angularfire2。 https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md

这很好用,我的数据正在输入,但是在为生产构建时出现此错误:

您似乎正在使用 Firebase JS 的开发版本 开发工具包。将 Firebase 应用部署到生产环境时,建议 仅导入您打算使用的各个 SDK 组件。

对于 CDN 构建,这些可通过以下方式获得 (替换为组件的名称 - 即 auth、数据库、 等):

我尝试了所有建议,但没有任何效果。

有什么想法吗? 谢谢,

根模块

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { RootComponent } from './rootComponent.component';
import { ROOT_ROUTES } from './root.routes';
import { BrowserModule, Title } from '@angular/platform-browser';
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [RootComponent],
  imports: [
    AngularFireModule.initializeApp(environment.firebase),
    AngularFirestoreModule,
    NoopAnimationsModule,
    BrowserModule,
    RouterModule.forRoot(ROOT_ROUTES)
  ],
  providers: [Title],
  bootstrap: [RootComponent]
})
export class RootModule {}

组件

import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material';
import { AngularFirestore } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
import { ActivatedRoute } from '@angular/router';
import { Seal } from '../seals.types';
import { StudioService } from '../../../service/studio.service';

@Component({
    selector: 'seals-component',
    templateUrl: './seals.component.html'
})
export class SealsComponent implements OnInit {

    constructor(private db:AngularFirestore, private studioService: StudioService) {
        this.getData();
    }

    items: Observable<any[]>;
    dataSource = new MatTableDataSource<Seal[]>();;
    displayedColumns: string[] = ['description', 'language', 'seal', 'type'];
    pID:string = 'flsjezlijlsfj';

    ngOnInit() {}

    getData() {
        this.items = this.db.collection(`sealsDB/TNDorQMQOzoqY6P6Ej0i/seal/${this.pID}/seal/`).valueChanges();
        this.items.subscribe(seals => {
            this.dataSource.data = seals
        })
    }
}

【问题讨论】:

    标签: google-cloud-firestore angular6 angularfire2 angularfire5


    【解决方案1】:

    我收到了同样的警告,我花了一段时间才发现我使用的是来自firebase/authUser 接口,以及其他文件中的Timestamp.fromDate()

    所以我补充说:

    import * as firebase from 'firebase/app';
    import { User } from 'firebase/auth';
    

    只是

    import * as firebase from 'firebase/app';
    

    我用过的地方

    firebase.firestore.Timestamp.fromDate()
    

    这消除了警告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-06
      • 2018-11-22
      • 1970-01-01
      • 2020-09-24
      • 2021-05-03
      • 1970-01-01
      • 2019-01-17
      • 2017-12-13
      相关资源
      最近更新 更多