7***@qq.com
7***@qq.com
  • 发布:2023-08-08 14:53
  • 更新:2023-09-05 15:20
  • 阅读:156

uni.chooseImage拍照无法获取图片

分类:uni-app

场景:uniapp内嵌web-view,H5页面通过message调用相机拍照。然后uniapp 获取到图片,转化为base64,然后把图片给到内嵌的H5页面。

问题:
1、从相册选择没有问题。
2、调用拍照功能,拍照完成之后,使用

let reader = new plus.io.FileReader();  
// @ts-ignore  
reader.readAsDataURL(filePath);//tempFilePaths[0]  
reader.onloadend = function (e: any) {  
    console.log(e);  
    resolve(e.target["result"])  
}

保存:

{  
    "type": "loadend",  
    "bubbles": false,  
    "cancelBubble": false,  
    "cancelable": false,  
    "lengthComputable": false,  
    "loaded": 0,  
    "total": 0,  
    "target": {  
        "fileName": "_doc/uniapp_temp_1691467335324/camera/1691467339764.jpg",  
        "readyState": 2,  
        "result": null,  
        "error": {  
            "code": 10,  
            "message": "执行出错"  
        },  
        "onloadstart": null,  
        "onprogress": null,  
        "onload": null,  
        "onabort": null,  
        "onerror": null,  
        "onloadend": "function() { [native code] }"  
    }  
}
2023-08-08 14:53 负责人:无 分享
已邀请:
piaoyi_UI

piaoyi_UI - 【插件开发】【专治疑难杂症】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=193663(微信搜索飘逸科技UI小程序直接体验)】【骗子请绕道】问题咨询请加QQ群:120594820,代表作灵感实用工具小程序

看了半天,没有看出啥,是已经解决了还是没有解决

3***@qq.com

3***@qq.com

new plus.io.FileReader() 感觉这个API已经废了

要回复问题请先登录注册