当前位置:网站首页>vant3+ts h5页面嵌套进app 与原生app通信
vant3+ts h5页面嵌套进app 与原生app通信
2022-06-12 17:41:00 【热忱学习】
最近的项目是vant3+ts 做的h5 嵌套在app里面,有扫码和拍照的功能需要与原生app 交互
用到的插件是dsBridge

在
/**
* @Description 调用相机扫码,异步调用
* 返回参数:就是扫码返回的值
scanCode 是APP那变定义的方法名,str 就是返回的参数
*/
function getScanCode(callback: any) {
let res = ''
dsBridge.call('scanCode', function (str: any) {
res = str
callback(res)
})
return res
}
/**
* @Description 调用相机拍照和选取图片
* 返回参数:就是扫码返回的值
takePhoto 是APP那变定义的方法名 ,size是限制的选择的张数,返回的是项目名称和base64字符串
*/
function getPhoto(callback: any) {
let res = ''
dsBridge.call('takePhoto', {size:4}, function (_res) {
res = _res
callback(res)
})
return res
}
在需要调用页面的地方 这样写,处理自己想要的逻辑
边栏推荐
猜你喜欢

全局锁、表锁、行锁

Kill program errors in the cradle with spotbugs

LCD参数解释及计算

Cesium抛物线方程

php 实现无限极分类树(递归及其优化)

Yyds dry goods inventory leetcode question set 911 - 920

Volcano engine held a video cloud technology force summit and released a new experience oriented video cloud product matrix

Qiushengchang: Practice of oppo commercial data system construction

How to view, modify, and delete SSH

Compilation optimization of performance optimization
随机推荐
(3) Golang - data type
论文《Deep Interest Evolution Network for Click-Through Rate Prediction》
Vulnhub[DC3]
Introduction of one object one code tracing system
Memory control of node
消息队列实战之队列优先级
Sizepolicy policy in layout management
JDBC几个坑
The R language uses the tablestack function of epidisplay package to generate statistical analysis tables based on grouped variables (including descriptive statistical analysis, hypothesis test, diffe
Application case of smart micro 32-bit MCU for server application cooling control
分辨率与行场同步信号的关系 场消隐
C#操作数据库增查业务数据值内容案例学校表
Understanding of binary search
Quick start sweep crawler framework
Are Huishang futures accounts reliable? Is the fund safe?
73. 矩阵置零(标记法)
AlibabaProtect.exe如何删除、卸载
LCD参数解释及计算
MySQL transaction introduction and transaction isolation level
DRM 驱动 mmap 详解:(一)预备知识