标签:func data console ons var bsp date style 使用
var rowData=[ {data:4,date:‘06‘,code:‘cr_3‘,name:‘桥吊3‘}, {data:1,date:‘03‘,code:‘cr_1‘,name:‘桥吊1‘}, {data:2,date:‘01‘,code:‘cr_2‘,name:‘桥吊2‘}, {data:1,date:‘07‘,code:‘cr_1‘,name:‘桥吊1‘}, {data:2,date:‘02‘,code:‘cr_2‘,name:‘桥吊2‘}, {data:1,date:‘09‘,code:‘cr_1‘,name:‘桥吊1‘}, {data:2,date:‘03‘,code:‘cr_2‘,name:‘桥吊2‘} ]; var arr=rowData.reduce(function(o,v,i){ if(o[v.code]){ o[v.code].push(v.data); }else{ o[v.code]=[v.data]; } return o; },{}) console.log(arr);
返回的结果
{ "cr_1":[1,1,1], "cr_2":[2,2,2], "cr_4":[4] }
标签:func data console ons var bsp date style 使用
原文地址:http://www.cnblogs.com/pengfei25/p/7652381.html