一维数组分页

// ==========================================================================一维数组分页

    var you = [{
            "categoryId": "51f9da1731d65584ab001f15",
            "categoryName": "母婴",
            "categoryPic": "201410241058583658.png",
            "shopCount": 9
        }, {
            "categoryId": "51f9da1731d65584ab001f16",
            "categoryName": "家居",
            "categoryPic": "201410241057599841.png",
            "shopCount": 12
        }, {
            "categoryId": "51f9da1731d65584ab001f17",
            "categoryName": "美食",
            "categoryPic": "201410241058318991.png",
            "shopCount": 22
        }, {
            "categoryId": "524556e83b9c89db0607e3a6",
            "categoryName": "生活服务",
            "categoryPic": "201410241057355704.png",
            "shopCount": 4
        }, {
            "categoryId": "51f9da1731d65584ab001f17",
            "categoryName": "美食",
            "categoryPic": "201410241058318991.png",
            "shopCount": 22
        }, {
            "categoryId": "524556e83b9c89db0607e3a6",
            "categoryName": "生活服务",
            "categoryPic": "201410241057355704.png",
            "shopCount": 4
        },{
            "categoryId": "51f9da1731d65584ab001f15",
            "categoryName": "母婴",
            "categoryPic": "201410241058583658.png",
            "shopCount": 9
        }, {
            "categoryId": "51f9da1731d65584ab001f16",
            "categoryName": "家居",
            "categoryPic": "201410241057599841.png",
            "shopCount": 12
        }, {
            "categoryId": "51f9da1731d65584ab001f17",
            "categoryName": "美食",
            "categoryPic": "201410241058318991.png",
            "shopCount": 22
        }, {
            "categoryId": "524556e83b9c89db0607e3a6",
            "categoryName": "生活服务",
            "categoryPic": "201410241057355704.png",
            "shopCount": 4
        }, {
            "categoryId": "51f9da1731d65584ab001f17",
            "categoryName": "美食",
            "categoryPic": "201410241058318991.png",
            "shopCount": 22
        }, {
            "categoryId": "524556e83b9c89db0607e3a6",
            "categoryName": "生活服务",
            "categoryPic": "201410241057355704.png",
            "shopCount": 4
        }, {
            "categoryId": "524556e83b9c89db0607e3a6",
            "categoryName": "生活服务",
            "categoryPic": "201410241057355704.png",
            "shopCount": 4
        }];
    var wei = [];
    for(i = 0 ; i < you.length; i++){
        if(i%4 == 0){
            wei.push([]);
        }
        wei[wei.length-1].push(you[i])
    }
    console.log(wei);

 

posted @ 2016-07-11 12:09  星堡a  阅读(205)  评论(0编辑  收藏  举报