//云端代码 const db = uniCloud.database() exports.main = async (event, context) => { const collection = db.collection(event.name) const docList = await collection.where(event.data).get() if (!docList.data || docList.data.length === 0) { return { status: -1, msg: '没有查询到数据' } } const res = await collection.doc(docList.data[0]._id).remove() if (res.deleted === 1) { return { status: 0, msg: '成功删除一条数据' } } else { return { status: -2, msg: '删除数据失败' } } }; //前端代码 remove(){ uni.showLoading({ title: '处理中...' }) uniCloud.callFunction({ name: 'remove', data: { name: 'unicloud-test', data: { "leixing": "分类" } } }).then((res) => { uni.hideLoading() uni.showModal({ content: res.result.msg, showCancel: false }) console.log(res) }).catch((err) => { uni.hideLoading() uni.showModal({ content: `删除失败,错误信息为:${err.message}`, showCancel: false }) console.error(err) }) },
标签:const,数据,res,remove,移除,msg,uni,data From: https://www.cnblogs.com/zzl00770/p/17983599