我遇到了这个问题
Not allowed to load local resource: 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 camera plugin returns source with protocol for new captures but when using it in your HTML to set the source of an element like img or video you need to remove protocol
您可以在这里阅读更多相关信息:Ionic 3: File_URI Not allowed to load local resource IOS
希望对您有所帮助!
关于javascript - 不允许加载本地资源 : Ionic3(ios),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50206596/