|
楼主 |
发表于 2016-6-8 18:24:17
|
显示全部楼层
demo提供的案例页面中 执行到 navigator.camera.getPicture(onSuccess, onFail, {quality : 50}); 这句就出错了
可以帮忙解释下吗
------------------------------------------------------------------------
require("$UI/system/lib/cordova/cordova");
require("css!$UI/demo/device/common/pub").load();
require("cordova!org.apache.cordova.camera");
require("cordova!org.apache.cordova.media-capture");
require("cordova!org.apache.cordova.inappbrowser");
var Model = function() {
this.callParent();
this.STORE_ID = "com.justep.demo.advice.cameradata"; //
};
//从内存中取出历史记录
Model.prototype.modelLoad = function(event){
var me = this;
document.addEventListener("deviceready", onDeviceReady, false);
// 加载完成
function onDeviceReady() {
me.comp("cameraBtn").set({disabled: false});
me.comp("captureBtn").set({disabled: false});
if(localStorage.getItem(me.STORE_ID) !== "")
me.comp("fileData").loadData(JSON.parse(localStorage.getItem(me.STORE_ID)));
}
};
//拍照
Model.prototype.cameraBtnClick = function(event) {
var operateLabel = this.getElementByXid("operateLabel");
var resultLabel = this.getElementByXid("resultLabel");
$(operateLabel).text("开始拍照!");
$(resultLabel).text("");
var data = this.comp("fileData");
function onSuccess(imageURI) {
data.newData({index : 0});
data.setValue("filePath", imageURI);
data.setValue("fileName", imageURI.substr(imageURI.lastIndexOf('/') + 1));
data.setValue('createTime', justep.Date.toString(new Date(), justep.Date.DEFAULT_FORMAT ));
$(resultLabel).text("成功"+imageURI);
}
$(operateLabel).text("开始拍照!!");
function onFail(message) {
$(resultLabel).text("失败:"+message);
}
$(operateLabel).text("开始拍照!!!");
navigator.camera.getPicture(onSuccess, onFail, {quality : 50});
$(operateLabel).text("开始拍照!!!!");
}; |
|