欧美日韩精品一区二区在线线,一级无码在线收看,精品国产高清91,久久精品欧美电影

# camera

基礎(chǔ)庫(kù) 1.6.0 開始支持,低版本需做兼容處理。

微信 Mac 版:支持

微信 鴻蒙 OS 版:支持

相關(guān)文檔: wx.createCameraContext

渲染框架支持情況:Skyline (使用最新 Nightly 工具調(diào)試)、WebView

# 功能描述

系統(tǒng)相機(jī)。掃碼二維碼功能,需升級(jí)微信客戶端至6.7.3。需要用戶授權(quán) scope.camera2.10.0起 initdone 事件返回 maxZoom,最大變焦范圍,相關(guān)接口 CameraContext.setZoom。

# 通用屬性

屬性 類型 默認(rèn)值 必填 說(shuō)明 最低版本
mode string normal 應(yīng)用模式,只在初始化時(shí)有效,不能動(dòng)態(tài)變更 2.1.0
合法值 說(shuō)明
normal 相機(jī)模式
scanCode 掃碼模式
resolution string medium 分辨率,不支持動(dòng)態(tài)修改 2.10.0
合法值 說(shuō)明
low
medium
high
device-position string back 攝像頭朝向 1.0.0
合法值 說(shuō)明
front 前置
back 后置
flash string auto 閃光燈,值為auto, on, off 1.0.0
合法值 說(shuō)明 最低版本
auto 自動(dòng)
on 打開
off 關(guān)閉
torch 常亮 2.8.0
frame-size string medium 指定期望的相機(jī)幀數(shù)據(jù)尺寸 2.7.0
合法值 說(shuō)明
small 小尺寸幀數(shù)據(jù)
medium 中尺寸幀數(shù)據(jù)
large 大尺寸幀數(shù)據(jù)
bindstop eventhandle 攝像頭在非正常終止時(shí)觸發(fā),如退出后臺(tái)等情況 1.0.0
binderror eventhandle 用戶不允許使用攝像頭時(shí)觸發(fā) 1.0.0
bindinitdone eventhandle 相機(jī)初始化完成時(shí)觸發(fā),e.detail = {maxZoom} 2.7.0
bindscancode eventhandle 在掃碼識(shí)別成功時(shí)觸發(fā),僅在 mode="scanCode" 時(shí)生效 2.1.0

# Bug & Tip

  1. tip: 同一頁(yè)面只能插入一個(gè) camera 組件
  2. tip:請(qǐng)注意原生組件使用限制
  3. tip:onCameraFrame 接口根據(jù) frame-size 返回不同尺寸的原始幀數(shù)據(jù),與 Camera 組件展示的圖像不同,其實(shí)際像素值由系統(tǒng)決定

# 示例代碼

在開發(fā)者工具中預(yù)覽效果

<!-- camera.wxml -->
<camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>
<button type="primary" bindtap="takePhoto">拍照</button>
<view>預(yù)覽</view>
<image mode="widthFix" src="{{src}}"></image>
// camera.js
Page({
  takePhoto() {
    const ctx = wx.createCameraContext()
    ctx.takePhoto({
      quality: 'high',
      success: (res) => {
        this.setData({
          src: res.tempImagePath
        })
      }
    })
  },
  error(e) {
    console.log(e.detail)
  }
})