交集,切割数组

let cartIds = [] // 定义选中的购物车id
this.result.forEach(item => {
cartIds.push(item.cartId)
})
test = this.cartList.filter((item, index) => {
return cartIds.indexOf(item.cartId) === -1
})
console.log(test)
this.cartList = test

切割数组
sliceArray (array, size) {
var result = []
for (var x = 0; x < Math.ceil(array.length / size); x++) {
var start = x * size
var end = start + size
result.push(array.slice(start, end))
}
return result
},

posted @ 2018-04-27 10:11  沙滩多啦图  阅读(157)  评论(0编辑  收藏  举报