Camera
System camera.
Type
ComponentType<CameraProps>
CameraProps
Property | Type | Default | Required | Description |
---|---|---|---|---|
mode | "normal" | "scanCode" | "normal" | No | Application mode. It is valid only during initialization, and cannot be dynamically changed. |
resolution | "low" | "medium" | "high" | "medium" | No | Resolution, no dynamic changes supported. |
devicePosition | "front" | "back" | "back" | No | The facing orientation of the camera. |
flash | "auto" | "on" | "off" | "torch" | "auto" | No | The flash. Values include auto, on, and off. |
frameSize | "medium" | "small" | "large" | "medium" | No | Specifies the expected size of camera frame data |
scanArea | number[] | No | Scan 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" | |
onStop | BaseEventOrigFunction<any> | No | Triggered when the camera is closed unexpectedly, for example, exiting the background. | |
onError | BaseEventOrigFunction<any> | No | Triggered when the camera is not authorized. | |
onInitDone | BaseEventOrigFunction<onInitDoneEventDetail> | No | Triggered after the camera is initialized | |
onScanCode | BaseEventOrigFunction<any> | No | Triggered when a scanned QR code is recognized. It is valid only when mode="scanCode". |
Property Support
API | WeChat Mini-Program | H5 | React 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
Value | Description |
---|---|
normal | Camera mode |
scanCode | Scanning mode |
resolution
Valid values of resolution
Value | Description |
---|---|
low | low |
medium | medium |
high | high |
devicePosition
Valid values of device-position
Value | Description |
---|---|
front | Front-facing camera |
back | Rear-facing camera |
flash
Valid values of flash
Value | Description |
---|---|
auto | Auto |
on | On |
off | Off |
torch | Always bright |
frameSize
Valid values of frame-size
Value | Description |
---|---|
small | Small-size frame data |
medium | Medium-size frame data |
large | Large-size frame data |
onInitDoneEventDetail
Param | Type | Description |
---|---|---|
maxZoom | number | Maximum zoom |
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Camera | ✔️ | ✔️ |