Home > Mobile >  Do a small program reads a phone number, in res. Result. The list on the result of [0] out of the qu
Do a small program reads a phone number, in res. Result. The list on the result of [0] out of the qu

Time:11-28

Originally follow suit: https://developers.weixin.qq.com/community/develop/article/doc/000c462925c610ecc899b11d751013
Should be output as shown in figure:
Results output as shown in figure:

Author res. Result. The list can normal output line cloudID [0], my res. Result. The list [0] output cloudID dozens of lines, each line one character
For help

CodePudding user response:

Cloud function JS:
//cloud function entry file
Const cloud=the require (' wx - server - SDK)

Cloud. The init ()

//cloud function entry function
Exports. The main=async (event, the context)=& gt; {
The console. The log (' upload cloudID 'event. The cloudID)
Return await cloud. GetOpenData ({list: event. The cloudID})
}
JS page:
Page ({
GetPhoneNumber (e) {
The console. The log (' click on the button for development data, e);
Wx. Cloud. CallFunction ({
Name: 'getPhone'
Data: {cloudID: e.d etail. CloudID}
}). Then (res=& gt; {
The console. The log (' success 'res)
//the console. The log (' print ', e.d etail. CloudID)

Enclosing setData ({
Index: 'access to the mobile phone number: + res. Result. The list [0]. PhoneNumber
})
}). The catch (err=& gt; {
The console. The log (' access failure, err)
})
},
})

WXML:
  • Related