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

本文介绍了在Vue项目中如何在获取到接口数据后,向数据中添加一行新数据的方法,分为添加数据前后两个阶段,并详细阐述了实现过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、添加数据前

二、添加数据后

三、实现方法

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

 

转载于:https://www.cnblogs.com/wangyuxue/p/11326279.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值