更新记录
1.0.0(2026-04-21)
下载此版本
{
"name": "legacy-camera",
"id": "legacy-camera",
"version": "1.0.0",
"description": "基于 camera-sdk-release.aar 的 UniApp Android 原生相机插件",
"_dp_nativeplugin": {
"android": {
"plugins": [
{
"type": "module",
"name": "LegacyCameraModule",
"class": "com.xygala.uniplugin.LegacyCameraModule"
}
],
"integrateType": "aar",
"dependencies": [
"com.alibaba:fastjson:1.2.83"
],
"abis": [
"armeabi-v7a",
"arm64-v8a"
],
"useAndroidX": true
}
}
}
平台兼容性
uni-app(5.07)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| √ |
√ |
- |
- |
√ |
√ |
√ |
- |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
<button @click="start">开始预览</button>
<button @click="switchCam">切换镜头</button>
<button @click="shoot">拍照</button>
<button @click="stop">停止预览</button>
<button @click="destroy">销毁</button>
{{ filePath }}
{{ lastEvent }}
{
this.lastEvent = JSON.stringify(event)
if (event.event === 'cameraError') {
uni.showToast({ title: event.message || '相机异常', icon: 'none' })
}
})
await camera.init({})
},
methods: {
async start() {
const res = await camera.startPreview({ facing: CameraFacing.BACK })
if (res.code !== 0) {
uni.showToast({ title: res.msg, icon: 'none' })
}
},
async switchCam() {
await camera.switchCamera()
},
async shoot() {
const res = await camera.takePicture()
if (res.code === 0) {
this.filePath = res.data.filePath || ''
} else {
uni.showToast({ title: res.msg, icon: 'none' })
}
},
async stop() {
await camera.stopPreview()
},
async destroy() {
await camera.destroy()
}
},
onUnload() {
camera.offEvent()
camera.destroy()
}
}
<style>
.page {
display: flex;
flex-direction: column;
gap: 16rpx;
padding: 24rpx;
}
.path {
font-size: 24rpx;
}
</style>