简体中文
scanCode
约 188 字小于 1 分钟
2025-08-11
扫码功能适配
参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| opts | Object | 是 | 配置选项对象 |
| opts.onSuccess | Function | 是 | 成功回调函数 |
| opts.onFail | Function | 是 | 失败回调函数 |
返回值
无返回值,通过回调函数返回结果。
成功回调参数 (onSuccess)
| 参数名 | 类型 | 说明 |
|---|---|---|
| errorCode | Number | 错误码,0 表示成功 |
| success | Boolean | 是否成功,true 表示成功 |
| result | String | 扫码结果 |
失败回调参数 (onFail)
| 参数名 | 类型 | 说明 |
|---|---|---|
| error | String | 错误信息 |
使用示例
(function(root) {
root.jsapiAdapter = {
scanCode(opts) {
jsBridge.invokie('scanCode', {
onSuccess(res){
// 调用第三方APP原生的获取位置信息成功
opts.onSuccess({
errorCode: 0,
success: true,
result: res.result
});
},
onFail() {
options.onFail('调用失败');
}
})
}
}
})jsBridge
第三方APP提供的原生桥接接口
