JSON数据(test.json)
[{
"name": "A Goofy Movie (1995) 720p HDTVRip x264 Eng Subs [Dual Audio] [Hindi DD 2.0 - English DD 2.0] Exclusive By -=!Dr.STAR!=-",
"progress": 0,
"size": "1.06 GB",
"downloaded": "87.98 KB",
"hash": "8fe65e43464debe1bc0961e4656ea780368d4fba",
"peer": 0,
"delete": "delete.php?del=8fe65e43464debe1bc0961e4656ea780368d4fba",
"speed": "0 Byte",
"eta": "23:59:59",
"path": "C:\\xampp\\htdocs\\final\\download\/8fe65e43464debe1bc0961e4656ea780368d4fba"
}, {
"name": "Logan+2017+HDCAM+XviD+UnKnOwN",
"progress": 0,
"size": "0 Byte",
"downloaded": "0 Byte",
"hash": "624911f8e4fc172e5ed7970d3bc097198bfd4e76",
"peer": 0,
"delete": "delete.php?del=624911f8e4fc172e5ed7970d3bc097198bfd4e76",
"speed": "0 Byte",
"eta": "23:59:59",
"path": "C:\\xampp\\htdocs\\final\\download\/624911f8e4fc172e5ed7970d3bc097198bfd4e76"
}, {
"name": "Internet Download Manager 6.27 Build 5 Multilingual + Patch",
"progress": 100,
"size": "6.97 MB",
"downloaded": "7.49 MB",
"hash": "bffe600ae08ba8e55db30dae6acd86979e30ce15",
"peer": 0,
"delete": "delete.php?del=bffe600ae08ba8e55db30dae6acd86979e30ce15",
"speed": "0 Byte",
"eta": "23:59:59",
"path": "C:\\xampp\\htdocs\\final\\download\/bffe600ae08ba8e55db30dae6acd86979e30ce15"
}]
KnockoutJS 数据
function ExampleViewModel() {
var self = this;
self.ExampleData = ko.observableArray([]);
self.update = function() {
$.ajax("test.json", {
success: function(allData) {
var mappeddata = $.map(allData, function(item) {
return new DataItem(item)
});
self.ExampleData(mappeddata);
}
});
}
}
function DataItem(data) {
ko.observable(data.name);
ko.observable(data.progress);
}
var exampleViewModel = new ExampleViewModel();
ko.applyBindings(exampleViewModel);
如何提供分页并仅显示前两个值?