dlt.scanCode
Introduction
Launches the client's scanning interface for scanning.
Parameters
Object object
Attribute | Type | Default Value | Required | Description | Compatibility |
---|---|---|---|---|---|
onlyFromCamera | boolean | Yes | Whether to support selecting a scanning file from the image library | ||
autoJump | boolean | true | No | Whether to automatically jump when a mini program QR code is recognized. By default, it automatically jumps | Supported by basic library version 2.10.0 or higher |
sceneId | string | No | Scene value | Supported by basic library version 2.10.0 or higher | |
success | function | No | Callback function for a successful API call | ||
fail | function | No | Callback function for a failed API call | ||
complete | function | No | Callback function for the end of an API call (executed for both successful and failed calls) |
Return Value
Attribute | Type | Description |
---|---|---|
data | string | Scanning result |
autoJump | boolean | Whether it has automatically jumped to the mini program |
success | string | true-successfully set false-failed to set |
Sample Code
// pages/index/index.js
Page({
scanCode() {
dlt.scanCode({
onlyFromCamera: true,
autoJump: true,
success: (res) => {
console.log('success', res.data);
},
fail: (res) => {
console.log('fail', res);
},
complete: (res) => {
console.log('complete', res);
},
});
},
});