backbone.js 无法加载资源:不支持的url

7tofc5zh  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(180)

我的代码在以下行中抛出此错误Failed to load resource: unsupported url

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

这是imageData的值:

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

当在iPhone模拟器上运行cordova应用程序时,使用Xcode中的cordova-plugin-camera 2.4.1 "Camera"插件部署目标设置为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插件-相机2.4.1“相机”
1.1.0“兼容”插件
4.3.2“文件”
cordova-plugin-file-transfer 1.6.2“文件传输”
1.3.2“白名单”
控制台0.2.11“控制台”

qxgroojn

qxgroojn1#

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

相关问题