服务端返回的是个数组,界面需要能滑动,每个滑动区块都是八个,所以要将数组进行分组.
//1.数据
var data=[
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'},
{cateName:'手机'}
];
againGroup (data,num){
var result=[];
for(var i=0,len=data.length;i<len;i+=num){
result.push(data.slice(i,i+num));
}
return result;
}
againGroup(data,8);//数组就按照8个进行分组了;