当前位置:网站首页>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
}
在需要调用页面的地方 这样写,处理自己想要的逻辑
边栏推荐
- Authorization in Golang ProjectUseing Casbin
- Volcano engine held a video cloud technology force summit and released a new experience oriented video cloud product matrix
- The R language uses the tabpct function of the epidisplay package to generate a two-dimensional contingency table, and uses the mosaic diagram to visualize the contingency table (two-dimensional conti
- JDBC快速入门教程
- 字节飞书人力资源套件三面
- Vulnhub[DC3]
- Arm64棧回溯
- 5、Embedding
- Arm64 Stack backtrack
- Quick start sweep crawler framework
猜你喜欢

Cesium抛物线方程

迄今微软不同时期发布的SQL Server各版本之间的大致区别,供参考查阅

C#操作数据库增查业务数据值内容案例学校表

Byte flybook Human Resources Kit three sides

Selenium element positioning

Kill program errors in the cradle with spotbugs

How to win the "Olympic Games" in retail technology for jd.com, the learning tyrant of the "regular examination"?

进阶之大山-asp.net core 路由程序基础使用演示0.1

《用户体验要素:以用户为中心的产品设计》笔记
![[CSP]202012-2期末预测之最佳阈值](/img/40/9b59bd692bcfe05d16614cc6d55d1f.png)
[CSP]202012-2期末预测之最佳阈值
随机推荐
73. matrix zeroing (marking method)
Kali2022 installing Armitage
Byte flybook Human Resources Kit three sides
32-bit MCU mm32f0040 with smart micro high performance M0 kernel
Volcano engine held a video cloud technology force summit and released a new experience oriented video cloud product matrix
EasyCode模板
Feedback compilation
系统设计之图状数据模型
String s = null ; String s = new String();String s =““ ;String s ;有什么区别?
JDBC快速入门教程
Getting started with grpc swift
ssm常用到的依赖
Evolution and thinking of Taobao native R & D mode | DX R & D mode
Arm64 Stack backtrack
JDBC several pits
(3) Golang - data type
SQL游标(cursor)详细说明及内部循环使用示例
TensorFlow2训练数据集的两种方式
TensorFlow求梯度时提示TypeError: unsupported operand type(s) for *: ‘float‘ and ‘NoneType‘
Interesting LD_ PRELOAD