第一种.lodash.js 项目中可以引入lodash.js ( _chunk(arr,size) )
import _ form 'lodash';
let arr = [1,2,3,4,5,6,7,8];
let dataList = [];
dataList = _chunk(arr,3); //[ [1,2,3],[4,5,6],[7,8] ]
第二种
let arr = [1,2,3,4,5,6,7,8];
let dataList = [];
for(let i=0;i<this.arr.length;i+=4){
dataList.push(this.arr .slice(i,i+4))
}
//[ [1,2,3,4],[5,6,7,8] ]