【问题标题】:Not allowed to load local resource: Ionic3(ios)不允许加载本地资源:Ionic3(ios)
【发布时间】:2018-10-16 19:27:27
【问题描述】:

我遇到了这个问题

不允许加载本地资源: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 中我无法避免这个问题,我确信这是由于一些安全问题,如果有人帮助我会很棒。

【问题讨论】:

    标签: javascript file cordova camera ionic3


    【解决方案1】:

    我认为这样的事情可能对你有用:

    if (isIos()) {
      itemSrc = itemSrc.replace(/^file:\/\//, '');
    }
    

    基于我看到的另一个线程:

    iOS 相机插件返回带有新捕获协议的源代码,但在 HTML 中使用它来设置 img 或 video 等元素的源代码时,您需要删除协议

    您可以在此处阅读更多信息:Ionic 3: File_URI Not allowed to load local resource IOS

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2016-10-08
      • 2016-11-04
      • 1970-01-01
      • 2014-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多