无法加载资源:不支持 url
Failed to load resource: unsupported url
我的代码在以下行中抛出此错误 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-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-file 4.3.2 "File"
cordova-plugin-file-transfer 1.6.2 "File Transfer"
cordova-plugin-whitelist 1.3.2 "Whitelist"
org.apache.cordova.console 0.2.11 "Console"
通过将 navigator.camera.DestinationType.NATIVE_URI;
替换为 navigator.camera.DestinationType.FILE_URI
解决了这个问题
我的代码在以下行中抛出此错误 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-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-file 4.3.2 "File"
cordova-plugin-file-transfer 1.6.2 "File Transfer"
cordova-plugin-whitelist 1.3.2 "Whitelist"
org.apache.cordova.console 0.2.11 "Console"
通过将 navigator.camera.DestinationType.NATIVE_URI;
替换为 navigator.camera.DestinationType.FILE_URI