如图:当点击确定后,更新数据库,在数据库增加一个字段,在JS中能够成功添加,当在云函数中实现时,添加不了
在这段代码中,能够成功添加:
confirm(e){
const that = this;
console.log(e);
const itmelength = that.data.code;
const id = that.data.id;
const wehicles = that.data.wehicles;
db.collection("wehicle").doc(id).update({
data:{
top:{
itmelength:itmelength,
pud_data:new Date(),
}
}
})
.then(res => {
console.log(res);
})
},
在云函数中添加不了:
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext();
const openid = wxContext.OPENID;
const itmelength = event.itmelength;
const id = event.id;
console.log(id);
return await db.collection("wehicle").doc(id).update({
data:{
"top":_.push({
itmelength:itmelength,
pud_data:new Date(),
})
}
})
}
js代码:
confirm(e){
const that = this;
console.log(e);
const itmelength = that.data.code;
const id = that.data.id;
const wehicles = that.data.wehicles;
wx.cloud.callFunction({
name:'topping',
data:{
top:{
itmelength:itmelength,
}
},
success:res => {
console.log(res);
}
})
}
看你的截图even.id不是空的吗
wx.cloud.callFunction({
name:“topping“,
data:{
id:id,
top:{
itmelength:itmelength,
pud_data:new Date(),
}
},
success:res => {
console.log(res);
}
})
Event RequestId: 6fc9a044-2156-4a1e-8901-435e1addcae4
这个是什么?是不是这个ID错了?const id = event.id;这个是点击置顶按钮时的ID,
/**
* 置顶弹窗
*/
showCode(event){
console.log(event);
const id = event.currentTarget.dataset.id
console.log(id)
this.setData({
show_input:true,
id:id
})
},
自己看看云函数运行日志啊