以Promise风格调用: 支持
拍摄照片。需要先通过
属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| quality | string | original | 否 | 成像质量 |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
值 | 说明 |
|---|---|
| low | 低质量 |
| normal | 普通质量 |
| original | 原图质量 |
| high | 高质量 |
属性 | 类型 | 说明 |
|---|---|---|
| tempImagePath | string | 照片临时文件路径,为 xhsfile:// 协议路径 |
| errMsg | string |
xhs.createCameraContext().takePhoto({
quality: 'normal', // 成像质量:low / normal / original / high
success: (res) => {
console.log('拍照成功:', res);
console.log('照片路径:', res.tempImagePath); // xhsfile:// 协议的临时路径
},
fail: (err) => {
console.error('拍照失败:', err.errMsg);
},
complete: () => {
console.log('takePhoto 调用结束');
}
});