...我就不细说了,你们自己体会下
云函数 index.js
'use strict';
//微信下小程序 :程序员实用资源
const db = uniCloud.database()
exports.main = async (event, context) => {
switch(event.action){//根据传参不同调用不同方法
case "edit":
return edit(event)
break;
case "remove":
return remove(event)
break;
}
};
async function edit(params) {
return {
res: 1
}
}
async function remove(params) {
return {
res: 2
}
}
然后客户端调用
uniCloud.callFunction({
name: 'aaa',
data: {
action:"edit",//这个参数调用进云函数的edit方法
}
}).then((res) => {
debugger
}).catch((err) => {
});