我試圖讓相機從一個按鈕上工作,但在下面的註釋行中出現錯誤。我正在使用Phonegap/Cordova(v2.1)提供的文檔。任何幫助讚賞。未定義相機和PictureSourceType Phonegap
var pictureSource = navigator.Camera.PictureSourceType.CAMERA; // Cannot read PictureSourceType of undef
var destinationType = navigator.camera.DestinationType.FILE_URI;
function onPhotoURISuccess(imageURI) {
var placeImage = document.getElementById('placeImage');
placeImage.src = imageURI;
placeImage.style.display = 'block';
console.log(imageURI);
}
function getPhoto() {
navigator.Camera.getPicture(onPhotoURISuccess, onFail, { //I am getting an error for this line saying camera is not defined?
quality: 50,
destinationType: camera.destinationType.FILE_URI,
sourceType: pictureSource
});
}
function onFail(message) {
alert('Failed because: ' + message);
}
你能讀取destinationType嗎?你在腳本中包含了cordova.js嗎? – cggaurav
嗨cggaurav,我在我的腳本中有這個。 我還沒有包含onDeviceReady函數,因爲我已經在使用前一個測試數據庫了。它是否正確?在拍照之前我應該能夠到達目的地嗎? – Inkers
http://docs.phonegap.com/en/2.0.0/cordova_camera_camera.md.html,應該是navigator.camera而不是navigator.Camera? – cggaurav