///android_asset/www/apis/camera.js:在文件无法读取未定义类型的属性格式“DATA_URL”45 [英] Can not read propery 'DATA_URL' of undefined type at file:///android_asset/www/apis/camera.js:45

查看:281
本文介绍了///android_asset/www/apis/camera.js:在文件无法读取未定义类型的属性格式“DATA_URL”45的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常新的PhoneGap应用程序,但我的机器人developer.I我试图调用摄像头在我的PhoneGap application.Following点击一个按钮是我的html在那里我打电话take_pic()API camera.js方法javascript.I只看到API的例子后,包括身体camera.js。

 <身体GT;
<标签=你好>的Hello World< /标签>
< BR><输入类型=提交ID =提交值=通话摄像头的onclick =take_pic();>
<脚本类型=文/ JavaScript的字符集=utf-8SRC =的API / camera.js>< / SCRIPT>
< /身体GT;

以下是这也是引发camera.js的方法,但它会抛出在文件无法读取未定义类型的属性格式DATA_URL':///android_asset/www/apis/camera.js:45的错误。请家伙帮我out.let我知道,如果需要更多的细节。

 函数take_pic(){
  navigator.camera.getPicture(onPhotoDataSuccess,函数(前){
    警报(相机错误!);
  },{质量:30,destinationType:destinationType.DATA_URL});
}


解决方案

你试下code?它是在PhoneGap的API的例子: PhoneGap的例子

  VAR pictureSource; //图片来源
VAR destinationType; //设置返回值的格式//等待设备API库加载
//
document.addEventListener(deviceready,onDeviceReady,FALSE);//设备API可用
//
功能onDeviceReady(){
    pictureSource = navigator.camera.PictureSourceType;
    destinationType = navigator.camera.DestinationType;
}功能take_pic(){
    navigator.camera.getPicture(onPhotoDataSuccess,函数(前){
        警报(相机错误!);
    },{质量:30,destinationType:destinationType.DATA_URL});
}

我觉得你的问题是变量destinationType是不确定的。你有没有正确初始化呢?

I am very much new to phonegap applications but i am an android developer.I am trying to call camera on a button click in my phonegap application.Following is my html where i am calling take_pic() method of camera.js api javascript.I have included camera.js in body after seeing api example only.

<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>

following is the method of camera.js which is triggered but it throws "Can not read propery 'DATA_URL' of undefined type at file:///android_asset/www/apis/camera.js:45" error .Please guys help me out.let me know if more details are required

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

解决方案

Did you try the next code? it is in the PhoneGap API examples: PhoneGap example

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 });
}

I think your problem is that the variable "destinationType" is undefined. Did you initialized it properly?

这篇关于///android_asset/www/apis/camera.js:在文件无法读取未定义类型的属性格式“DATA_URL”45的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆