Nah*_*nda 6 firebase angularfire angular
从 '@angular/fire/firestore' 导入 { AngularFirestoreModule } ;// => 错误
模块“@angular/fire/firestore”没有导出成员“AngularFirestoreModule”
包.json
“@角/火”:“^7.0.4”,
小智 14
我遇到了同样的问题,并且在 GitHub 存储库(https://github.com/angular/angularfire)中解释了如何调整新版本的代码
import { Firestore, collectionData, collection } from '@angular/fire/firestore';
import { Observable } from 'rxjs';
...
item$: Observable<Item[]>;
constructor(firestore: Firestore) {
const collection = collection(firestore, 'items');
this.item$ = collectionData(collection);
}
Run Code Online (Sandbox Code Playgroud)
您还必须更改在 app.module.ts 中初始化应用程序的方式
import { provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
@NgModule({
imports: [
provideFirebaseApp(() => initializeApp({ ... })),
provideFirestore(() => getFirestore()),
],
...
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8144 次 |
| 最近记录: |