//云端代码 const db = uniCloud.database() exports.main = async (event, context) => { const collection = db.collection(event.name) const res = await collection.where(event.data).get() return res }; //前台代码 getdata() { uni.showLoading({ title: '处理中...' }) uniCloud.callFunction({ name: 'getdata', data: { name: 'unicloud-test', data: { "leixing": "分类" } } }).then((res) => { uni.hideLoading() uni.showModal({ content: `查询成功,获取数据列表为:${JSON.stringify(res.result)}`, showCancel: false }) console.log(res) }).catch((err) => { uni.hideLoading() uni.showModal({ content: `查询失败,错误信息为:${err.message}`, showCancel: false }) console.error(err) }) },
标签:const,res,collection,查询,条件,uni,getdata,event From: https://www.cnblogs.com/zzl00770/p/17983532