HomeDocs
Skip to main content

dlt.scanCode

Introduction​

Launches the client's scanning interface for scanning.

Parameters​

Object object

AttributeTypeDefault ValueRequiredDescriptionCompatibility
onlyFromCamerabooleanYesWhether to support selecting a scanning file from the image library
autoJumpbooleantrueNoWhether to automatically jump when a mini program QR code is recognized. By default, it automatically jumpsSupported by basic library version 2.10.0 or higher
sceneIdstringNoScene valueSupported by basic library version 2.10.0 or higher
successfunctionNoCallback function for a successful API call
failfunctionNoCallback function for a failed API call
completefunctionNoCallback function for the end of an API call (executed for both successful and failed calls)

Return Value​

AttributeTypeDescription
datastringScanning result
autoJumpbooleanWhether it has automatically jumped to the mini program
successstringtrue-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);
},
});
},
});
Privacy agreementDeveloper agreementcontact us: developer_private.mi@dlightek.com © 2024 MiniApp. All Rights Reserved.