【发布时间】:2019-08-14 07:43:43
【问题描述】:
我正在尝试对来自 firebase 实时数据库的数据进行分页。
我必须更改为 firestore 吗? Google 的文档 (https://firebase.google.com/docs/firestore/query-data/query-cursors) 中的所有内容都在哪里解释,或者 rtdb 也可以?
这是我的代码(我正在使用 vue js):
loadConcerts ({commit}) {
commit('setLoading', true)
firebase.database().ref('concerts')
.orderByChild('expires')
.startAt(Date.now() / 1e3)
.limitToFirst(10)
.once('value')
.then(data => {
const concerts = []
data.forEach(element => {
concerts.push({
id: element.key,
title: element.val().title,
day: element.val().day,
ticketlink: element.val().ticketlink,
description: element.val().descriptio
})
})
commit('setLoadedConcerts', concerts)
commit('setLoading', false)
})
.catch(
(error) => {
console.log(error)
commit('setLoading', false)
}
)
},
I would like to add pagination after 10 results, or infinite scrolling.
【问题讨论】:
-
我认为描述有错别字n
标签: vue.js firebase-realtime-database google-cloud-firestore