javascript - 不允许加载本地资源:Ionic3(ios)
问题描述
我收到了这个问题
不允许加载本地资源:file:///var/mobile/Containers/Data/Application/AB6EABD9-CAAF-4AE5-91F9-D8042B34EA87/tmp/cdv_photo_002.jpg
我的代码看起来像
let cameraOptions = {
quality: 50,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
this.camera.getPicture(cameraOptions).then((imageData) => {
this.myImage = imageData;
})
在 android 设备中它工作正常,但在 ios 中我无法避免这个问题,我确信这是由于一些安全问题,有人帮助我会很棒。
解决方案
我认为这样的事情可能对你有用:
if (isIos()) {
itemSrc = itemSrc.replace(/^file:\/\//, '');
}
基于我看到的另一个线程:
iOS 相机插件返回带有新捕获协议的源,但是在 HTML 中使用它来设置 img 或 video 等元素的源时,您需要删除协议
你可以在这里阅读更多信息:Ionic 3: File_URI Not allowed to load local resource IOS
我希望这会有所帮助!
推荐阅读
- java - 当前日期作为 Springfox 和 Swagger-UI 中的示例
- python - 从excel和python绘制的图表有什么区别?
- mysql - 如果记录不存在,如何在 group_concat 中添加空值?
- linq - LINQ 更新查询未更新 Xamarin 表单应用程序中的数据库记录
- node.js - 在 ubuntu 的后台运行 node js 应用程序
- c# - 如何获取在asp.net中使用我的webapi的请求url?
- batch-file - Window shell - 如果在文件中找到文本,则输出日志
- javascript - 如何防止手持设备在使用画布签名板时打开键盘?
- go - Cron Job 不使用 TimeZone 触发
- java - 即使从浏览器 api 调用复制粘贴 JSONObject.toString("variable") 声明字段也不存在