android - 不允许加载本地资源:ionic 3 android
问题描述
我正在使用 ionic 3 android build apk 并尝试从file:///storage/emulated/0/data/io.ionic.vdeovalet/cache/image.jpeg 加载图像
拍摄图片(来源类型){ 尝试 { // 为相机对话框创建选项 变量选项 = { 质量:100, 目的地类型:this.camera.DestinationType.FILE_URI, encodingType:this.camera.EncodingType.JPEG, 源类型:源类型, }; this.camera.getPicture(options).then((imagePath) => { // Android 库的特殊处理 if (this.platform.is('android') && sourceType === this.camera.PictureSourceType.PHOTOLIBRARY) { this.filePath.resolveNativePath(imagePath) .then(filePath => { let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1); 让 currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1, imagePath.lastIndexOf('?')); this.copyFileToLocalDir(correctPath, currentName, this.createFileName()); this.lastImage = 文件路径; }); } 别的 { var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1); var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1); this.copyFileToLocalDir(correctPath, currentName, this.createFileName()); } },(错误)=> { this.presentToast('选择图片时出错'); }); } 抓住 (e) { 控制台.错误(e); } }
错误:不允许加载本地资源
android 6.0.1
解决方案
无需降级只需编写此代码。
private win: any = window;
this.win.Ionic.WebView.convertFileSrc(path);
推荐阅读
- protocols - 如何确定 KNX 设备是否能够发送扩展帧?
- oauth-2.0 - Xero OAuth2 问题
- nic - 对于 XDP-eBPF 上的 ipv6-Srv6 数据包,rx_queue_index 始终返回值 1
- python - 在python中的格式化方法中使用大写方法
- python-3.x - 将所有嵌套的 xml InfoTables 转换为 Python 字典
- java - 如何从firebase数据库中以文本形式显示我的数据实时我的代码和我的XML在
- php - 字符串语法 - 代码中出现 PHP 意外的 'if' (T_IF)
- webserver - 我在 Windows10 上安装了“本地”,然后将其卸载....为什么仍然有这么多“虚构大学”的实例在运行?
- node.js - NodeJS selenium-driver geckodriver 普通 Firefox
- flutter - 如何将红色星号符号添加到颤动的文本格式中