一、添加數據前
二、添加數據后
三、實現方法
setPayWaySummaryList() {
// summaryArr格式和接口的要一樣,summaryArr為添加到data的第三條數據 const summaryArr = { cash: 0, pos: 0, wechat: 0, cb: 0, bc: 0, name: '合計', }; const arrLength = this.statisticalQuery.length;// 查詢接口數據數組長度 for (let i = 0; i < arrLength; i++) { summaryArr.cash += this.statisticalQuery[i].cash || 0; summaryArr.pos += this.statisticalQuery[i].pos || 0; summaryArr.wechat += this.statisticalQuery[i].wechat || 0; summaryArr.cb += this.statisticalQuery[i].cb || 0; summaryArr.bc += this.statisticalQuery[i].bc || 0; } this.statisticalQuery.push(summaryArr); },