reactjs - 如何从firebase数据库中的开始和结束索引中检索行
问题描述
我正在我的项目中尝试分页功能,我正在使用对 firebase 的反应。
我的问题陈述:如果我的数据库中有大约 50 条记录,如果我们要选择记录 3 - 8,查询是什么?
解决方案
如果您想在前端使用特定字段,请使用切片,我认为您可以从后端返回所有列表,然后从 ui 端切片。
let arr = [
{id:1,name:'One'},
{id:2,name:'Two'},
{id:3,name:'Three'},
{id:4,name:'Four'},
{id:5,name:'Five'},
{id:6,name:'Six'},
{id:7,name:'Seven'},
{id:8,name:'Eight'},
{id:9,name:'Nine'},
{id:10,name:'Ten'}
]
let selected = arr.slice(2,8);
console.log(selected)
推荐阅读
- c - 如果我之前使用 memset,我还需要将 ptr 设置为 NULL 吗?
- python-3.x - 将列中的整数值模式转换为组
- java - MongoDB Group 操作返回文档而不是单个字段
- c++ - 将 `std::any` 转换为 `std::variant`
- node.js - Mongoose:如何向模式添加动态索引?
- javascript - 获取 Axios.get() 数据并在 React 组件中显示
- python - 我无法播放上传到管理员的音频(网址有引号)
- java - 在启用了 javascript 的情况下,无法在 heroku 上运行无头硒
- swift - UITableview显示一个项目而不是两个项目swift xcode
- r - 从缺失数据中抵消逐行校正影响的策略