我需要在我的 ApGyver 类固醇应用程序中显示捕获的图像。我捕获图像,然后尝试在我的图像中设置 src。但它给了我不允许本地资源的错误:
我以这种方式捕获图像:
var options = {
quality: 50,
targetWidth: 300,
targetHeight: 300,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA, // Camera.PictureSourceType.PHOTOLIBRARY
allowEdit: false,
encodingType: Camera.EncodingType.JPEG,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: true,
limit: 1
};
// capture callback
var captureSuccess = function(mediaFiles) {
var i, path, len;
console.log(mediaFiles);
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles[i].localURL;
// do something interesting with the file
}
if (switched) {
$scope.post.media = []
}
$scope.post.media.length = 1;
$scope.post.fileUrl = path;
setActionType('image');
$scope.isBusy = false;
console.log('hello' + path);
};
// capture error callback
var captureError = function(error) {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};
// start image capture
navigator.device.capture.captureImage(captureSuccess, captureError, options);