ios - 无法加载资源: unsupported url

标签 ios xcode cordova backbone.js camera

我的代码在以下行中抛出此错误无法加载资源:不支持的网址:

self.$el.find('.capturedImage').attr('src', imageData);

这是imageData的值:

assets-library://asset/asset.JPG?id=106E99A1-4F6A-45A2-B320-B0AD4A8E8473&ext=JPG

使用插件 cordova-plugin-camera 2.4.1“Camera”在 iPhone 模拟器上运行 cordova 应用程序时会发生这种情况 Xcode 中的部署目标设置为 9.0

render: function (context, template) {
        var self = this;
        View.__super__.render.apply(this, [context, template]);
        setTimeout(function() {
            var imageData = app.selectedYoungPerson.imageData;
            if (app.selectedYoungPerson.fromCamera) {
                if (imageData.indexOf('data:image/jpeg;base64,') != 0 && imageData.indexOf('data:;base64,') != 0) {
                    self.$el.find('.capturedImage').attr('src', "data:image/jpeg;base64," + imageData);
                }
            }else{
                    self.$el.find('.capturedImage').attr('src', imageData);
            }
            self.startCrop.apply(self,[]);
        }, 1000);

getBrowseImage: function(data) {
        var self = this;
        var destinationType = (navigator.userAgent.match(/iemobile/i)) ? navigator.camera.DestinationType.DATA_URL : navigator.camera.DestinationType.NATIVE_URI;
        navigator.camera.getPicture(function(imgData) {
                var fileName = 'img_'+(new Date()).valueOf()+'.jpg';
                if(data.callback) {
                    data.imgData = imgData;
                    data.fileName = fileName;
                    data.fromCamera = false;
                    data.callback.apply(data.ref, [data]);
                    //self.uploadImage(data);
                }
            }, function(err) {
                alert('Image cpature failed : '+err);
            }, {
                quality: 100,
                allowEdit: true,
                correctOrientation: true,
                destinationType: destinationType,
                sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
            }
        );
    },

这是我的插件列表:

cordova-plugin-camera 2.4.1“相机”

cordova-plugin-compat 1.1.0“兼容”

cordova-plugin-file 4.3.2"file"

cordova-plugin-file-transfer 1.6.2“文件传输”

cordova-plugin-whitelist 1.3.2“白名单”

org.apache.cordova.console 0.2.11“控制台”

最佳答案

通过将 navigator.camera.DestinationType.NATIVE_URI; 替换为 navigator.camera.DestinationType.FILE_URI 解决了此问题

关于ios - 无法加载资源: unsupported url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43881936/

相关文章:

ios - iOS 和 Android 设备之间通过 wifi 的消息传递应用程序

iphone - Apple AppStore 和开发者身份识别政策

iOS:本地化自白

iphone - 为什么我的委托(delegate)方法没有被调用?

android - Uncaught Error : SECURITY_ERR: DOM Exception 18 at file:///android_asset/www/js/DB. js

angularjs - 如何获取sqlite数据库中的表名

ios - 这个NSFetchRequest有什么问题?

ios - 在调用 awakeFromNib 之前是否可以在容器 View 中添加属性?

c++ - 文件打开失败!从文件中读取,c++,xcode

java - 在 android marshmallow (API v23) 上的 Cordova/phonegap 项目上添加运行时权限