当前位置:网站首页>【微信小程序】camera系统相机(79/100)
【微信小程序】camera系统相机(79/100)
2022-07-21 09:41:00 【lichong951】
UI布局:
<!--pages/camera/camera.wxml-->
<camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>
<button type="primary" bindtap="takePhoto">拍照</button>
<view>预览</view>
<image mode="widthFix" src="{
{src}}"></image>
数据模型& 控制器
// pages/camera/camera.js
Page({
/** * 页面的初始数据 */
data: {
},
takePhoto() {
const ctx = wx.createCameraContext()
ctx.takePhoto({
quality: 'high',
success: (res) => {
this.setData({
src: res.tempImagePath
})
}
})
},
error(e) {
console.log(e.detail)
},
/** * 生命周期函数--监听页面加载 */
onLoad(options) {
},
属性说明
属性 类型 默认值 必填 说明 最低版本
mode string normal 否 应用模式,只在初始化时有效,不能动态变更 2.1.0
合法值 说明
normal 相机模式
scanCode 扫码模式
resolution string medium 否 分辨率,不支持动态修改 2.10.0
合法值 说明
low 低
medium 中
high 高
device-position string back 否 摄像头朝向 1.0.0
合法值 说明
front 前置
back 后置
flash string auto 否 闪光灯,值为 auto , on, off 1.0.0
合法值 说明 最低版本
auto 自动
on 打开
off 关闭
torch 常亮 2.8.0
frame-size string medium 否 指定期望的相机帧数据尺寸 2.7.0
合法值 说明
small 小尺寸帧数据
medium 中尺寸帧数据
large 大尺寸帧数据
bindstop eventhandle 否 摄像头在非正常终止时触发,如退出后台等情况 1.0.0
binderror eventhandle 否 用户不允许使用摄像头时触发 1.0.0
bindinitdone eventhandle 否 相机初始化完成时触发,e.detail = {maxZoom} 2.7.0
bindscancode eventhandle 否 在扫码识别成功时触发,仅在 mode=“scanCode” 时生效 2.1.0
边栏推荐
- Pd 使用手册
- Compass Sinan
- Sentinel theoretical knowledge and introduction
- [213] interview questions asked by go language
- Redis基础知识、应用场景、集群安装
- Numpy04_线性代数(未写完)
- Commutateur H3C pour voir les commandes associées
- Resolved (selenium operation Firefox browser error) typeerror:__ init__ () got an unexpected keyword argument ‘firefox_ options‘
- MySQL insert data error
- Creation of gateway routing service
猜你喜欢
SQL每日一练(牛客新题库)——第3天: 条件查询
Example of implementing web server with stm32+enc28j60+uip protocol stack
RichView Table 表格对齐
Qt | Qt的项目文件.pro文件详解
[Development Tutorial 4] crazy shell · humanoid hip-hop robot PC upper computer online debugging
STM32+ENC28J60+UIP协议栈实现WEB服务器示例
Feign details, log configuration + contract settings + timeout + custom interceptors
thymeleaf应用笔记
[intensive reading of thesis]attention is all you need
web安全入门-TCP压力测试与防御
随机推荐
基于JSP实现OA办公系统
mysql插入数据报错
CONDA create, view, delete virtual environment
JS object: several ways to implement inheritance and their advantages and disadvantages
Yunyuanyuan (IX) | Devops chapter Jenkins installation and actual combat
QT | QT project documents Detailed explanation of pro file
指南针 司南
Example of implementing web server with stm32+enc28j60+uip protocol stack
一波骚操作,我把 SQL 执行效率提高了 10,000,000 倍
[learning notes] on Gaussian integer
Gateway route assertion factory, filter factory, cross domain processing
交换机基本原理与配置
js对象:实现继承的几种方式及优缺点
Solve the error omp: error 15: initializing libiomp5md dll, but found libiomp5md. dll already initialized
DHCP协议
[论文精读]Attention Is All You Need
Static distribution and dynamic distribution in trust
[213] interview questions asked by go language
Skywalking custom link tracking and performance analysis
Commutateur H3C pour voir les commandes associées