1
import * as React from 'react';
2 4
import { createHostComponent } from '@remax/shared';
3
import { BaseProps, GenericEvent } from '../../types/component';
4

5
export interface CameraProps extends BaseProps {
6
  /** (default: normal) 应用模式,只在初始化时有效,不能动态变更 2.1.0  */
7
  mode?: 'normal' | 'scanCode';
8
  /** 分辨率,不支持动态修改	2.10.0 */
9
  resolution?: 'low' | 'medium' | 'high';
10
  /** (default: back) 摄像头朝向 1.0.0 */
11
  devicePosition?: 'front' | 'back';
12
  /** (default: auto) 闪光灯,值为auto, on, off 1.0.0 */
13
  flash?: 'auto' | 'on' | 'off' | 'torch';
14
  /** (default: medium) 指定期望的相机帧数据尺寸 2.7.0 */
15
  frameSize?: 'small' | 'medium' | 'large';
16
  /** 摄像头在非正常终止时触发,如退出后台等情况 1.0.0 */
17
  onStop?: (event: GenericEvent) => any;
18
  /** 用户不允许使用摄像头时触发 1.0.0 */
19
  onError?: (event: GenericEvent) => any;
20
  /** 相机初始化完成时触发 2.7.0 */
21
  onInitDone?: (event: GenericEvent) => any;
22
  /** 在扫码识别成功时触发,仅在 mode="scanCode" 时生效 2.1.0 */
23
  onScanCode?: (event: GenericEvent) => any;
24
}
25
/**
26
 * https://developers.weixin.qq.com/miniprogram/dev/component/camera.html
27
 */
28 4
export const Camera: React.ComponentType<CameraProps> = createHostComponent<CameraProps>('camera');
29

30 4
Camera.defaultProps = {
31
  mode: 'normal',
32
  resolution: 'medium',
33
  devicePosition: 'back',
34
  flash: 'auto',
35
  frameSize: 'medium',
36
};

Read our documentation on viewing source code .

Loading