17 lines
326 B
JavaScript
17 lines
326 B
JavaScript
|
const arrTool = {
|
||
|
/**
|
||
|
* @description 一维数组变二维数组
|
||
|
* @param {Array} arr
|
||
|
* @param {Number} size
|
||
|
*/
|
||
|
oneArrToTwo(arr, size) {
|
||
|
var arrTwo = []
|
||
|
for (var i = 0; i < arr.length; i = i + size) {
|
||
|
arrTwo.push(arr.slice(i, i + size))
|
||
|
}
|
||
|
return arrTwo // 新的二维数组
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default arrTool;
|