一个大的json数组,大概有2000个对象,如何在前端实现分页

发布于 2022-09-04 02:57:26 字数 3127 浏览 15 评论 0

一个大的json数组,大概有2000个对象,如何在前端实现分页

[{"export_line":"2","export_state":"finished","line_total":"2","load_line":"2","load_state"
:"finished","name":"STUDENT","owner":"TEST"},{"export_line":"1","export_state":"finished","line_total"
:"1","load_line":"1","load_state":"finished","name":"STUDENT2","owner":"TEST"},{"export_line":"6","export_state"
:"finished","line_total":"6","load_line":"6","load_state":"finished","name":"HUAN1","owner":"TEST"},
{"export_line":"2","export_state":"finished","line_total":"2","load_line":"2","load_state":"finished"
,"name":"HUAN_TEST","owner":"TEST"},{"export_line":"1","export_state":"finished","line_total":"1","load_line"
:"1","load_state":"finished","name":"A1","owner":"TEST"},{"export_line":"1","export_state":"finished"
,"line_total":"1","load_line":"1","load_state":"finished","name":"A2","owner":"TEST"},{"export_line"
:"0","export_state":"finished","line_total":"0","load_line":"0","load_state":"finished","name":"DDS_TABLE_TEST6"
,"owner":"TEST"},{"export_line":"3","export_state":"finished","line_total":"3","load_line":"3","load_state"
:"finished","name":"DDS_TABLE_TEST5","owner":"TEST"},{"export_line":"3","export_state":"finished","line_total"
:"3","load_line":"3","load_state":"finished","name":"DDS_TABLE_TEST2","owner":"TEST"},{"export_line"
:"3","export_state":"finished","line_total":"3","load_line":"3","load_state":"finished","name":"DDS_TABLE_TEST3"
,"owner":"TEST"},{"export_line":"3","export_state":"finished","line_total":"3","load_line":"3","load_state"
:"finished","name":"DDS_TABLE_TEST4","owner":"TEST"},{"export_line":"0","export_state":"finished","line_total"
:"0","load_line":"0","load_state":"finished","name":"T1","owner":"TEST"},{"export_line":"0","export_state"
:"finished","line_total":"0","load_line":"0","load_state":"finished","name":"FUN_TAB","owner":"TEST"
},{"export_line":"6","export_state":"finished","line_total":"6","load_line":"6","load_state":"finished"
,"name":"fun_test_table","owner":"TEST"},{"export_line":"8192","export_state":"finished","line_total"
:"8192","load_line":"8192","load_state":"finished","name":"SWAP_T","owner":"TEST"},{"export_line":"134"
,"export_state":"finished","line_total":"134","load_line":"134","load_state":"finished","name":"objects_type"
,"owner":"TEST"},{"export_line":"12","export_state":"finished","line_total":"12","load_line":"12","load_state"
:"finished","name":"DDS_LOB1","owner":"TEST"},{"export_line":"600","export_state":"finished","line_total"
:"600","load_line":"600","load_state":"finished","name":"P_SWAP","owner":"TEST"},{"export_line":"0","export_state"
:"finished","line_total":"0","load_line":"0","load_state":"finished","name":"T03_11","owner":"TEST"}
,{"export_line":"0","export_state":"finished","line_total":"0","load_line":"0","load_state":"finished"
,"name":"TEST_IOT1","owner":"TEST"},{"export_line":"0","export_state":"finished","line_total":"0","load_line"
:"0","load_state":"finished","name":"T03","owner":"TEST"},{"export_line":"1","export_state":"finished"
,"line_total":"1","load_line":"1","load_state":"finished","name":"HUAN6","owner":"TEST"}.......]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

心凉 2022-09-11 02:57:26

根据每页显示条数,拆分成多个数组

data:[
    [{},{}],
    [{},{}]
]

根据当前页,读取对应数组

谈场末日恋爱 2022-09-11 02:57:26

简单点,直接js进行数组截取,比如每页10条,根据页数算截取的数组下标。
还可以直接服务器截取数组并返回,每次翻页都请求服务。

画离情绘悲伤 2022-09-11 02:57:26

获取第几页每页数量算一下,data[?]-data[?]就行。这种就是第一次慢,之后就很快了,但是服务器容易被搞垮。

请帮我爱他 2022-09-11 02:57:26

分页最好服务端那边分好,前端这边只要传页码过去就返回那一页的数据

小猫一只 2022-09-11 02:57:26

不错的插件:https://www.datatables.net/

但是这么多数据一次性给前端真的好???!!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文