出于分页的目的,我在使用Angular和Firestore的Ionic 3中使用了以下代码。
第一次请求:
collObs: Observable<any>;
more: Observable<any>;
this.collObs = this.afs.collection('data').limit(10).snapshotChanges().map(a=>{
return a.map(x=> {
return {
value: x.payload.doc.data(),
};
});
});然后,我在lastDocSnap变量中生成最后一个文档快照
在页面末尾加载更多内容:
this.more = this.afs.collection('data').startAfter(lastDocSnap).limit(10).snapshotChanges().map(a=>{
return a.map(x=> {
return {
value: x.payload.doc.data(),
};
});
});发布于 2018-06-14 01:10:21
如果它们都是数组,你可以像这样使用扩展运算符:
this.collObs = [...this.collObs, ...this.more]
如果它们都是对象,那么可以尝试使用obj.spread
this.collObs = {...this.collObs, ...this.more}
https://stackoverflow.com/questions/50842567
复制相似问题