just started to learn the front end,
source code in the "success" and "fail", why there are no colons?
I learned something like this.
is it written in a new way?
{
url: opts.loginUrl,
...
success: function(result) {},
fail: function(err) {}
}
< H1 > the source code is as follows: < / H1 >
wx.request({
url: opts.loginUrl,
header: header,
method: opts.method,
success (result) {
const data = result.data;
if (!data || data.code !== 0 || !data.data || !data.data.skey) {
return opts.fail(new Error(`${JSON.stringify(data)}`))
}
const res = data.data
if (!res || !res.userinfo) {
return opts.fail(new Error(`(${data.error}):${data.message}`))
}
//
Session.set(res)
opts.success(res.userinfo)
},
fail (err) {
console.error("")
opts.fail(err)
}
});
< H1 > Arrow functions also have colons < / H1 >
qcloud.login({
success: res => {
this.setData({ userInfo: res, logged: true })
util.showSuccess("")
},
fail: err => {
console.error(err)
util.showModel("", err.message)
}
})