如何修改查询结果的字段名?
查询结果是res
result: Array(3)
0: {_id: "1537", zhong: 2, wan: 2, zao: 0, }
1: {_id: "1531", zhong: 2, wan: 2, zao: 0, },
2: {_id: "1580", zhong: 2, wan: 2, zao: 0, }
我想要把查询结果是字段修改为其它的可以吗?
修改为
0: {id: "1537", zhiduan1, 2, zhiduan2: 2, zhiduan3: 0, }
1: {id: "1531", zhiduan1: 2, zhiduan2: 2, zhiduan3: 0, },
2: {id: "1580", zhiduan1: 2, zhiduan2: 2, zhiduan3: 0, }
方便后期,我可以用同一个excel云函数导出
for (let key in array0) {
zhdata.push({zhiduan1 : array0[key].yuefen,zhiduan2 : array0[key].zao});
}
for做循环吧
let that0 = this
wx.cloud.callFunction({
name: 'yueton-cha', //云函数
data: {
shitang: aphitangname0, //默认食堂
cttime: datasysrt, //当上月
},
success(res){
console.log("请求云函数成功",res)
that0.setData({
array0: res.result,
})
},
fail(res) {
console.log("请求云函数失败", res)
}