cordova 3.4.1显示摄像机未定义
我正在使用cordova创建一个允许用户拍照的应用程序,我的问题是navigator.camera变得不明确我在中遵循了这个过程 我的代码是cordova 3.4.1显示摄像机未定义,cordova,Cordova,我正在使用cordova创建一个允许用户拍照的应用程序,我的问题是navigator.camera变得不明确我在中遵循了这个过程 我的代码是 function TakePicture() { event.preventDefault(); if (!navigator.camera) { OpenModalDialog('Alert', 'Camera API not supported', '80%', '20%');
function TakePicture()
{
event.preventDefault();
if (!navigator.camera) {
OpenModalDialog('Alert', 'Camera API not supported', '80%', '20%');
return;
}
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: 1, // 0:Photo Library, 1=Camera, 2=Saved Album
encodingType: 0, // 0=JPG 1=PNG
saveToPhotoAlbum: true
};
navigator.camera.getPicture(
function (imageData) {
window.resolveLocalFileSystemURI(imageURI, resolveOnSuccess, fsFail);
//$('.employee-image', this.el).attr('src', "data:image/jpeg;base64," + imageData);
// var image = document.getElementById('myImage');
// image.src = imageURI;
},
function () {
OpenModalDialog('Alert', 'Error taking picture', '80%', '20%');
},
options);
return false;
}
function Browse()
{
if (!navigator.camera) {
OpenModalDialog('Alert', 'Camera API not supported', '80%', '20%');
return;
}
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
});
function onSuccess(imageData) {
// var image = document.getElementById('myImage');
// image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
OpenModalDialog('Alert', 'Failed because: ' + message, '80%', '20%');
}
}
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
OpenModalDialog('Alert',' Camera '+navigator.camera,'80%','20%');
}
我查了一下
在AndroidManifest和app/res/xml/config.xml中
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.CameraLauncher" />
</feature>
一切都很好,但摄像头仍然没有定义,即使我试着打电话给导航器。onDeviceReady中的摄像头也有,但没有运气,帮帮我。事件中有拼写错误。PrevedFault;它应该是event.preventDefault;也许这是造成错误的原因。同样在你的设备中,它应该是navigator.camera,你已经评论过了,而不是navigate.camerathanks,但是这是我犯的错误,但是我的代码中的每一件事都是正确的,我仍然收到了cameratry的未定义消息,要删除摄像头插件并重新安装。你是安装了摄像头插件还是默认添加的?通常在phonegap 3.x之后,您需要手动添加大部分本机功能摄像头、通讯录、可控震源等。thaks它现在正在工作。请更新您遵循的帮助您解决问题的整个过程。这将帮助查看您的问题的人。