Small micro-channel learning program 01

Use cloud functions

In the first project configuration file
project.config.json
configuration inside
"cloudfunctionRoot": "./ cloudfFn"

New cloudFn folder, let it be cloud folder function

Then the cloud function folder configuration Node.js function
syntax with an anonymous function js

the async = exports.main (Event, context) => {
const = wxContext cloud.getWXContext ()
the let {the userInfo, A, B} = Event
the let SUM = A + B
return {
Event,
OpenID: wxContext.OPENID,
AppID: wxContext .APPID,
unionid: wxContext.UNIONID,
SUM,
}
}
remember synchronization function to the cloud server

We need to add initialization in onLaunch within app.js
wx.cloud.init ()

Method call:
in the file called js, parameter passing as follows
wx.cloud.callFunction ({
name: 'Login',
Data: {
A:. 1,
B:. 5,
},
Complete: the console.log
})

Use wx.cloud.callFunction can perform a direct function of the parameters passed to the function name and function can, complete success is the callback function.

Guess you like

Origin www.cnblogs.com/Larry-AAAAA/p/11286136.html