This API is used via wx.getRandomValues(Object object).
Attribute | Type | Default value | Required | Description |
length | number | - | Yes | Integer, the byte size of the generated random number, with a maximum of 1048576. |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
Attribute | Type | Description |
randomValues | ArrayBuffer | Random number content, with a length equivalent to the passed-in byte size. |
wx.getRandomValues({length: 6 // Generate a random number of 6-byte length,success: res => {console.log(wx.arrayBufferToBase64(res.randomValues)) // Print after converting to a base64 string}})
Was this page helpful?