Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Angularjs 构建一个应用程序,其数据存储在 json 文件中,所以基本上我只需 $http 并将它们分类到模板中。
当每个 .json 约为 2kB 时,它非常好,现在超过 20kB,所以我正在考虑将 json 文件的各个部分分成更小的卡盘,这样每个块都将是客户端需要接收的内容以便在应用程序(或状态)中查看单个页面,仅此而已。但如果可能的话,我想保持文件原样。
那么,这是我的问题 - 是否可以在后端查询 json 文件并仅将查询的部分发送给客户端?如果是这样,怎么办?
谢谢
我能想到的唯一方法是为此使用服务器端代码。 例如,如果我们在服务器端使用 PHP,它将是这样的:
$string = file_get_contents("file.json"); $json_a = json_decode($string, true); // server side pagination
做一些经典的服务器端分页。