当前位置:网站首页>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
}
在需要调用页面的地方 这样写,处理自己想要的逻辑
边栏推荐
- Learn the mitmproxy packet capturing tool from scratch
- 1723. minimum time to complete all work
- 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
- 一物一码追踪溯源系统介绍
- Recognize function originality
- 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
- 使用MongoDB官方go库操作MongoDB原创
- 数据库SQL操作基础
- Kali2022安装armitage
- Some introduction to FPC flexible circuit board design
猜你喜欢

文章名字

How to change Golan back to the English version when it becomes the Chinese version

消息队列存储消息数据的 MySQL 表格

Introduction to several common functions of fiddler packet capturing (stop packet capturing, clear session window contents, filter requests, decode, set breakpoints...)

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

Use GCC's PGO (profile guided optimization) to optimize the entire system

Exclusive interview with oppo find X5 Product Manager: deeply cultivate self-developed chips to create the ultimate flagship experience with the highest standards

消息队列实战之队列优先级

Quick start sweep crawler framework

A variety of Qt development methods, which do you choose?
随机推荐
406. 根据身高重建队列
Arm64栈回溯
Gerrit triggers Jenkins sonarqube scan
(3) Golang - data type
Figma from getting started to giving up
Array sorts in the specified order
Tidb Hackathon 2021 - pcloud: conduct icloud pcloud team interview on the database
MySQL学习笔记
A variety of Qt development methods, which do you choose?
Figma从入门到放弃
grpc-swift入门
Detailed description of SQL cursor and example of internal recycling
Feedback compilation
迄今微软不同时期发布的SQL Server各版本之间的大致区别,供参考查阅
Advanced mountain -asp Net core router basic use demo 0.1
R language uses ggplot2 to visualize the density graph (curve) of specific data columns in dataframe data, and uses Xlim parameter to specify the range of X axis
qemu+gdb小节
Hangzhou AI developer meetup registration opens!
Enterprise internal online training system source code
(5) Outputs and outputs