更新记录
1.0.0(2026-06-05)
平台兼容性
uni-app(5.07)
| Vue2 |
Vue3 |
Vue3插件版本 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
iOS插件版本 |
鸿蒙 |
| - |
√ |
1.0.0 |
- |
- |
- |
- |
× |
15 |
1.0.0 |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(5.07)
| Chrome |
Safari |
Android |
iOS |
iOS插件版本 |
鸿蒙 |
微信小程序 |
| - |
- |
× |
15 |
1.0.0 |
- |
- |
温馨提示 如何调用插件
import {
recognitionText
} from 'uni_modules/yuange-iosocr'
文字识别
// filePath 本地图片文件的绝对路径
// iOS示例: file:///var/mobile/Containers/Data/Application/xxx/Documents/xxx.PNG
recognitionText(filePath,{
success(res) {
console.log(JSON.stringify(res));
},
fail(err) {
console.log(JSON.stringify(err));
}
})
回调结果数据格式
{
"data": "识别结果xxxxxx",
"code": 200,
"msg": "操作成功"
}
{
"code": 500,
"msg": "操作失败"
}
完整的Demo示例
<template>
<button @click="ocr" class="button">本地OCR文字识别</button>
<view class="text-area">
<text class="title">{{msg}}</text>
</view>
</template>
<script>
import {
recognitionText
} from "@/uni_modules/yuange-iosocr"
export default {
data() {
return {
msg: ""
}
},
onLoad() {
},
methods: {
ocr() {
let that = this;
// 使用uniapp提供的选择图片API
uni.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 从相册选择或拍照
success(res) {
let tempFilePath = res.tempFilePaths[0];
console.log('filepath====' + tempFilePath);
// 调用OCR插件进行文字识别
recognitionText(tempFilePath, {
success(res) {
console.log(JSON.stringify(res));
that.msg = JSON.stringify(res);
},
fail(err) {
console.log(JSON.stringify(err));
that.msg = JSON.stringify(err);
}
});
},
fail(err) {
console.log(JSON.stringify(err));
that.msg = JSON.stringify(err);
}
});
}
},
}
</script>
<style>
.title {
font-size: 36rpx;
color: black;
}
.button {
background-color: dodgerblue;
color: white;
}
</style>