- .splice 删除某条评论后,数据库没有删除该条数据,而是变成了 null ,怎么处理呢?
.splice 删除某条评论后,数据库没有删除该条数据,而是变成了 null ,怎么处理呢?
2022-02-23 - 用手机取消点赞后,后台不是直接删除点赞数据,而是变成了null,但是模拟器点赞取消就没问题,为啥?
prizeAction(e){ var that = this if(app.globalData.userInfo == null){ wx.navigateTo({ url: '/pages/auth/auth', }) }else{ console.log('dianzanid',that.data.id) db.collection('actions').doc(that.data.id).get({ success(res){ var action = res.data var tag = false var index for(var i in action.prizeList){ if(action.prizeList[i].openid == app.globalData.openid){ tag = true index = i break } } if(tag){ action.prizeList.splice(index,1) console.log(action) db.collection('actions').doc(that.data.id).update({ data:{ prizeList:action.prizeList, prizeList_length:action.prizeList.length }, success(res){ console.log("旧人",res) wx.showToast({ title: '取消成功', }) that.getDetail() } }) }else{ var user = {} user.nickName = app.globalData.userInfo.nickName user.faceImg = app.globalData.userInfo.avatarUrl user.openid = app.globalData.openid action.prizeList.push(user) console.log(action.prizeList) db.collection('actions').doc(that.data.id).update({ data:{ prizeList:action.prizeList, prizeList_length:action.prizeList.length }, success(res){ console.log("新人",res) wx.showToast({ title: '点赞成功', }) that.getDetail() } }) } } }) } },
2022-02-22