更新记录

1.0.1(2026-01-19)

1.0.0 (2026-01-19)

首次发布

快速使用

1. 引入组件

<sw-system-camera-view ref="cameraRef" @photoSaved="onPhotoSaved" class="live-pusher" :style="{ width: screenWidth + 'px', height: screenHeight + 'px' }"> </sw-system-camera-view>

2. 拍照功能

在页面定义拍照方法,调用插件暴露出的 takePhotoNoArg 方法:

const ref = this.$refs['cameraRef']
const canCall = !!(ref && ref.takePhotoNoArg)
console.log('cameraRef ready:', !!ref, 'method exists:', canCall)

if (!canCall) {
  uni.showToast({ title: '相机未就绪', icon: 'error' })
  return
}

try {
  if (ref.takePhotoNoArg) {
    ref.takePhotoNoArg()
    return
  }
  uni.showToast({ title: '拍照未就绪', icon: 'error' })
} catch (e) {
  console.error('调用拍照失败:', e)
  uni.showToast({ title: '拍照失败', icon: 'error' })
}

3. 接收图片

通过绑定 @photoSaved 方法接收拍照后的图片路径:

onPhotoSaved(res) {
  if (typeof res === 'string' && res.indexOf('Error') === 0) {
    uni.showToast({ title: '拍照失败', icon: 'error' })
    return
  }
  // 注意:部分场景下可能直接返回路径,部分场景返回事件对象,需根据实际情况处理
  this.photoPath = res.detail
  console.log('收到插件拍照数据:', res.detail)
}

1.0.0(2026-01-19)

快速使用: <sw-system-camera-view ref="cameraRef" @photoSaved="onPhotoSaved" class="live-pusher" :style="{ width: screenWidth + 'px', height: screenHeight + 'px' }"> 1、拍照: 在页面定义拍照方法,然后调用插件暴露出的拍照: const ref = this.$refs['cameraRef'] const canCall = !!(ref && ref.takePhotoNoArg) console.log('cameraRef ready:', !!ref, 'method exists:', canCall) if (!canCall) { uni.showToast({ title: '相机未就绪', icon: 'error' }) return } try { if (ref.takePhotoNoArg) { ref.takePhotoNoArg() return } uni.showToast({ title: '拍照未就绪', icon: 'error' }) } catch (e) { console.error('调用拍照失败:', e) uni.showToast({ title: '拍照失败', icon: 'error' }) } 2、接收拍照后的图片,通过绑定方法: onPhotoSaved(res) { if (typeof res === 'string' && res.indexOf('Error') === 0) { uni.showToast({ title: '拍照失败', icon: 'error' }) return } this.photoPath = res.detail console.log('收到插件拍照数据:', res.detail)
},


平台兼容性

uni-app(4.87)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - - - - - - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - -

其他

多语言 暗黑模式 宽屏模式
× ×

隐私、权限声明

1. 本插件需要申请的系统权限列表:

相机权限:android.permission.CAMERA

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。