我正在开发 Angular(版本 9.1.13) 我正在使用 Firestore 、Fire 版本 ("@angular/fire": "^6.1.5") 、Firebase 版本 ("firebase": "^8.10.1") 作为数据库的项目。我正在尝试使用带有
where
、orderBy
和 limit
方法的查询从 Firestore 获取数据。这是我的代码:
const ref: CollectionReference = this.firestore.collection(this.path()).ref;
let query: Query = collectionRef
.where(...conditions...)
.where(...conditions...)
.orderBy('time', 'desc')
.limit(5);
this.subscription = query.snapshotChanges().subscribe((changes) => {}
但是我在 query.snapshotChanges 行收到错误消息 - 属性 snapshotChanges 在类型 Query 上不存在
我的问题-
snapshotChanges()
方法特定于AngularFire库。
您的代码似乎使用的是常规的 Firebase SDK for JavaScript,但它没有
snapshotChanges()
,而是有一个方法 onSnapshot
。