无法读取属性'DATA_URL'的未定义类型file:///android_asset/www/apis

Can not read propery 'DATA_URL' of undefined type at file:///android_asset/www/apis/camera.js:45

本文关键字:file apis www asset android 类型 URL 读取 属性 DATA 未定义      更新时间:2023-09-26

我是phonegap应用程序的新手,但我是一名android开发人员。我正试图在我的phonegap应用程序中点击按钮调用摄像头。下面是我在html中调用camera.jsapijavascript的take_pic()方法。在只看到api示例后,我在body中包含了camera.js。

<body>
<label for="hello">Hello World</label>
<br><input type="submit" id="submit" value="Call Camera" onclick="take_pic();">
<script type="text/javascript" charset="utf-8" src="apis/camera.js"></script>
</body>

以下是camera.js的方法,该方法被触发,但它在file:///android_asset/www/apis/camera.js:45"错误。请大家帮我。如果需要更多的细节,请告诉我

function take_pic() {
  navigator.camera.getPicture(onPhotoDataSuccess, function(ex) {
    alert("Camera Error!");
  }, { quality : 30, destinationType: destinationType.DATA_URL });
}

您尝试了下一个代码吗?它在PhoneGap API示例中:PhoneGap示例

var pictureSource;   // picture source
var destinationType; // sets the format of returned value
// Wait for device API libraries to load
//
document.addEventListener("deviceready",onDeviceReady,false);
// device APIs are available
//
function onDeviceReady() {
    pictureSource=navigator.camera.PictureSourceType;
    destinationType=navigator.camera.DestinationType;
}
function take_pic() {
    navigator.camera.getPicture(onPhotoDataSuccess, function(ex) {
        alert("Camera Error!");
    }, { quality : 30, destinationType: destinationType.DATA_URL });
}

我认为您的问题是变量"destinationType"未定义。您是否正确初始化了它?