【发布时间】:2019-08-27 19:42:36
【问题描述】:
使用 bootstrap-vue 分页组件:
<b-pagination
v-model="currentPage"
:total-rows="rows"
:per-page="perPage"
></b-pagination>
组件.vue:
export default class Links extends Vue {
public currentPage: number = 1
public perPage: number = 20
public rows: number = 1
@Watch('currentPage')
onCurrentPageChange(page: number) {
const startAt = page * this.perPage - this.perPage
db.collection('links')
.orderBy('created', 'desc')
.startAt(startAt)
.limit(this.perPage)
.get()
.then(snap => {
console.log(snap.docs)
})
}
}
当currentPage 值更改时,我使用startAt 获取新的数据库值,但它什么也不返回。我的 Firestore 具有以下字段的文档:
- 创建(日期)
- 标题(字符串)
- 网址(字符串)
如何使用偏移量/限制进行正常分页?
【问题讨论】:
标签: javascript vue.js google-cloud-firestore