vue给请求接口数据增加一行新数据

一、添加数据前

二、添加数据后

三、实现方法

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); },

猜你喜欢

转载自www.cnblogs.com/wangyuxue/p/11326279.html