var data = [
{name:'xue',age:'20'},
{name:'bing',age:'21'},
{name:'hu',age:'22'},
{name:'wang',age:'23'},
{name:'li',age:'24'},
{name:'wan',age:'25'},
{name:'kang',age:'25'},
{name:'hua',age:'26'},
{name:'kai',age:'27'},
{name:'fang',age:'28'},
]
var result = [];
for(var i=0;i<data.length;i+=3){
result.push(data.slice(i,i+3));
}
console.log(result);
js把一个数组分割成每三个一组
于 2022-05-18 09:47:17 首次发布