Camera
Requires:
@ray-js/ray≥0.6.9
Description
System camera component for previewing and capturing.
Props
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
mode | "normal" | No | normal | Mode; only effective during initialization, cannot be changed dynamically |
resolution | "low" | "medium" | "high" | No | medium | Resolution, cannot be changed dynamically |
devicePosition | "front" | "back" | No | back | Camera facing |
flash | "auto" | "on" | "off" | "torch" | No | auto | Flash mode |
borderWidth | number | No | 0 | Border width, in px |
borderStyle | "solid" | "dashed" | No | solid | Border style |
borderColor | string | No | #ffffff | Border color; must be hex format |
borderRadius | number | No | 0 | Border radius, in px |
borderRadiusTopLeft | number | No | - | Top-left border radius, in px |
borderRadiusTopRight | number | No | - | Top-right border radius, in px |
borderRadiusBottomLeft | number | No | - | Bottom-left border radius, in px |
borderRadiusBottomRight | number | No | - | Bottom-right border radius, in px |
backgroundColor | string | No | #ffffff | Background color; must be hex format |
| No | - | Triggered when the camera terminates abnormally, e.g., when the app goes to the background | ||
| No | - | Triggered when camera access is denied by the user | ||
| No | - | Triggered when the camera is initialized | ||
updateLayout | unknown | No | - | Used for cross-layer components to notify the container layer to update styles |
Referenced Types
interface
CameraStopEventinterface
BaseEvent| Property | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Event type |
timeStamp | number | Yes | Time in milliseconds since the page opened |
| Yes | Source component of the event | ||
| Yes | Collection of property values for the current component | ||
mark | any | No | Event mark data |
interface
Target| Property | Type | Required | Description |
|---|---|---|---|
id | string | Yes | id of the event source component |
| Yes | Collection of custom attributes from the `dataset` on the event source component |
Valid Values
resolution
| Value | Description | Since |
|---|---|---|
low | Low resolution | - |
medium | Medium resolution | - |
high | High resolution | - |
devicePosition
| Value | Description | Since |
|---|---|---|
front | Front camera | - |
back | Rear camera | - |
flash
| Value | Description | Since |
|---|---|---|
auto | Auto flash | - |
on | Flash on | - |
off | Flash off | - |
torch | Torch mode | - |
borderStyle
| Value | Description | Since |
|---|---|---|
solid | Solid border | - |
dashed | Dashed border | - |
Examples
Basic usage
Custom border
Related Links
Related API: createCameraContext. This is a native component based on off-screen rendering. Please note the native component usage restrictions.
Scan with SmartLife App to Try
Download Sample CodeFAQ
- Only one
cameracomponent can be inserted on the same page. - Not supported in the Tuya MiniApp IDE.
- For related principles, refer to Native components based on off-screen rendering.
- Please note the native component usage restrictions.