let arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
let box = []
let son = []
arr.forEach(item=>{
if(son.length===8){
son = []
}
if(son.length===0){
box.push(son)
}
son.push(item)
})
console.log(box)
// 0: (8) [1, 2, 3, 4, 5, 6, 7, 8]
// 1: (8) [9, 10, 11, 12, 13, 14, 15, 16]
// 2: (2) [17, 18]
每个数组拿出来8条数据
最新推荐文章于 2023-01-04 22:18:44 发布