当前位置:网站首页>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
}
在需要调用页面的地方 这样写,处理自己想要的逻辑
边栏推荐
- Qiushengchang: Practice of oppo commercial data system construction
- Notes on user experience elements: user centered product design
- Saturated! Can't future programmers work anymore?
- SQL游标(cursor)详细说明及内部循环使用示例
- The significance of writing technology blog
- (5) Outputs and outputs
- 406. 根据身高重建队列
- 认识函数原创
- 电控学习 第二周
- A variety of Qt development methods, which do you choose?
猜你喜欢

全局锁、表锁、行锁

SSM集成FreeMarker以及常用语法

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

Hangzhou AI developer meetup registration opens!

5、Embedding

Gerrit triggers Jenkins sonarqube scan

LCD参数解释及计算

龙芯处理器内核中断讲解

Tcp/ip family structure and protocol of tcp/ip series overview

Evolution and thinking of Taobao native R & D mode | DX R & D mode
随机推荐
Gerrit triggers Jenkins sonarqube scan
AlibabaProtect.exe如何删除、卸载
三代DRI的变化
数组按指定顺序排序
How to win the "Olympic Games" in retail technology for jd.com, the learning tyrant of the "regular examination"?
32-bit MCU mm32f0040 with smart micro high performance M0 kernel
認識函數原創
The significance of writing technology blog
Continued 2 asp Net core router basic use demonstration 0.2 acquisition of default controller data
Is Huishang futures company reliable in opening accounts and safe in trading?
Quick start sweep crawler framework
Introduction of one object one code tracing system
R language uses the sum function of epidisplay package to calculate the descriptive statistical summary information of the specified variables in dataframe under different grouped variables and visual
ssm常用到的依赖
R language calculates data Table specifies the mean value of a numeric variable when the value of one grouped variable is fixed and another grouped variable
Alibaba cloud image station supports IPv6!
Article name
Kali2022 installing Armitage
消息队列实战之队列优先级
The R language uses the plot function to visualize the data scatter chart, and uses font The axis parameter specifies that the font type of the axis scale label is italic