3 回答
TA貢獻1951條經驗 獲得超3個贊
removeCost: function (item) {
let index = this.form.addReceiptsCostVOList.indexOf(item)
let ids = []
for (var i = 0; i < this.form.addReceiptsCostVOList.length; i++) {
ids.push(item.costId)
}
this.form.delCostIds = ids
for (let i = 0; i < ids.length; i++) {
this.form.addReceiptsCostVOList.splice(ids.length - 1 - i, 1)
}
console.log('form', this.form)
}
TA貢獻1803條經驗 獲得超6個贊
可以考慮使用閉包函數改造一下, 需要注意下this指向
removeCost: (() => {
let ids = []
this.form.delCostIds = ids
return (item) => {
let index = this.form.addReceiptsCostVOList.indexOf(item)
if (index !== -1) {
ids.push(item.costId)
this.form.addReceiptsCostVOList.splice(index, 1)
}
}
})()
添加回答
舉報
