不允许加载本地资源:Ionic3(iOS)

4

我遇到了这个问题:

不允许加载本地资源: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上我无法避免这个问题,我确定这是由于某些安全问题造成的,如果有人能帮助我就太好了。

1个回答

1
我认为以下内容可能适合您:

我认为以下内容可能适合您:

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

基于我看到的另一个主题:

iOS相机插件返回新捕获的协议源,但在使用它在HTML中设置元素(如img或video)的源时,需要删除协议。

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

希望这可以帮助!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接