Skip to main content
Version: Next

Camera

System camera.

Reference

Type

ComponentType<CameraProps>

CameraProps

PropertyTypeDefaultRequiredDescription
mode"normal" | "scanCode""normal"NoApplication mode. It is valid only during initialization, and cannot be dynamically changed.
resolution"low" | "medium" | "high""medium"NoResolution, no dynamic changes supported.
devicePosition"front" | "back""back"NoThe facing orientation of the camera.
flash"auto" | "on" | "off" | "torch""auto"NoThe flash. Values include auto, on, and off.
frameSize"medium" | "small" | "large""medium"NoSpecifies the expected size of camera frame data
scanAreanumber[]NoScan to identify area, result is [x, y, w, h],
is the upper left corner of the display area relative to the camera.
w,h is the area size in px. It is valid only when only mode="scanCode"
onStopBaseEventOrigFunction<any>NoTriggered when the camera is closed unexpectedly, for example, exiting the background.
onErrorBaseEventOrigFunction<any>NoTriggered when the camera is not authorized.
onInitDoneBaseEventOrigFunction<onInitDoneEventDetail>NoTriggered after the camera is initialized
onScanCodeBaseEventOrigFunction<any>NoTriggered when a scanned QR code is recognized.
It is valid only when mode="scanCode".

Property Support

APIWeChat Mini-ProgramH5React Native
CameraProps.mode✔️✔️
CameraProps.resolution✔️
CameraProps.devicePosition✔️✔️
CameraProps.flash✔️✔️
CameraProps.frameSize✔️
CameraProps.scanArea✔️
CameraProps.onStop✔️✔️
CameraProps.onError✔️✔️
CameraProps.onInitDone✔️✔️
CameraProps.onScanCode✔️✔️

mode

Valid values of mode

ValueDescription
normalCamera mode
scanCodeScanning mode

resolution

Valid values of resolution

ValueDescription
lowlow
mediummedium
highhigh

devicePosition

Valid values of device-position

ValueDescription
frontFront-facing camera
backRear-facing camera

flash

Valid values of flash

ValueDescription
autoAuto
onOn
offOff
torchAlways bright

frameSize

Valid values of frame-size

ValueDescription
smallSmall-size frame data
mediumMedium-size frame data
largeLarge-size frame data

onInitDoneEventDetail

ParamTypeDescription
maxZoomnumberMaximum zoom

API Support

APIWeChat Mini-ProgramH5React Native
Camera✔️✔️