This API is used via wx.scanCode(Object object).
Attribute | Type | Valid Values and Descriptions | Default value | Required | Description |
onlyFromCamera | boolean | - | false | No | Is it exclusively permissible to scan from the camera, disallowing the selection of images from the album? |
scanType | Array.<string> | barCode: Barcode qrCode: QR code datamatrix: Data Matrix code pdf417: PDF417 Barcode | ['barCode', 'qrCode'] | No | Code scanning type |
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 | Valid Values and Descriptions | Description |
result | string | - | Content of the scanned code |
scanType | string | QR_CODE: QR code AZTEC: Barcode CODABAR: Barcode CODE_39: Barcode CODE_93: Barcode CODE_128: Barcode DATA_MATRIX: QR code EAN_8: Barcode EAN_13: Barcode ITF: Barcode MAXICODE: Barcode PDF_417: QR code RSS_14: Barcode RSS_EXPANDED: Barcode UPC_A: Barcode UPC_E: Barcode UPC_EAN_EXTENSION: Barcode WX_CODE: QR code CODE_25: Barcode | Type of scanned code |
charSet | string | - | String set of the scanned code |
path | string | - | When the scanned code is the current mini program's QR code, this field will be returned, containing the path carried by the QR code. |
rawData | string | - | Raw data, Base64-encoded |
// Allow scanning from both the camera and albumwx.scanCode({success (res) {console.log(res)}})// Allow scanning from the camera onlywx.scanCode({onlyFromCamera: true,success (res) {console.log(res)}})
Was this page helpful?