getNewArray(array, subGroupLength) {
// array 代表一个数组
// subGroupLength 代表数组里面的数组的length值
let index = 0;
let newArray = [];
while (index < array.length) {
newArray.push(array.slice(index, (index += subGroupLength)));
}
return newArray;
},
方法是固定的,直接调用这个方法即可
this.list = this.getNewArray(list, 2);
打印出来的this.list就是一个二维数组