See the red comments
GetUserInfo: function (cb) {//cb is a function parameter?
Var that=this
If (this. GlobalData. The userInfo) {
Typeof cb=="function" & amp; & Cb (enclosing globalData. The userInfo) //this sentence what mean?? Cb this difficult to understand in c + +
} else {
//call the login interface
Wx. Login ({
Success: the function () {//here sucess is an arbitrary name it is in the login function call success function??
Wx. GetUserInfo ({
Success: the function (res) {
That. GlobalData. The userInfo=res. The userInfo
Typeof cb=="function" & amp; & Cb (that) globalData) the userInfo)
}
})
}
})
}
CodePudding user response:
Cb (function) is a method name of the method, can be used as another method of parameters, such as fun cb (); Fun (cb), x (cb) in x, cb becomes a function parameter of x, the second question: typeof is to obtain a variable of type, because cb is a function, so the typeof cb=="function" is to determine cb is a method, behind the meaning of the sentence is to call this method, the method statement will not perform, only call the execution, this and c + +, the third question, success is a small program API callback WeChat, is a fixed usageCodePudding user response:
@ m0_37894494 thank you for your question,