2
我已經在cordova2.0.0中創建了一個應用程序,在cordova的幫助下,我從Java腳本調用本機函數(用c編寫)。cordova 2.0.0給出未捕獲的TypeError:對象0沒有方法'func'
以前我是用的PhoneGap 1.0.0做其中的應用程序工作properly.but當我把它更新到2.0.0科爾多瓦,我得到的錯誤
08-07 15:24:12.527: I/Web Console(855): JSCallback Error: Request failed. at file:///android_asset/www/cordova-2.0.0.js:3698
08-07 15:22:27.815: E/Web Console(855): Uncaught TypeError: Object 0 has no method 'func' at file:///android_asset/www/file.js:359
任何一個可以請幫我出了這個問題。
代碼我的.html文件中:
<!DOCTYPE html>
<head>
<script type="text/javascript" charset="utf-8" src="cordova2.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="find.js"></script>
<script type="text/javascript">
function js_find(fthisval){
ws_find(socket,js_found);
}
function js_found(retval){
alert(retval);
}
function onBodyLoad(){
document.addEventListener("deviceready",onDeviceReady,false);
}
function onDeviceReady()
{
document.getElementById('d1').style.visibility = "visible";
}
</script>
</head>
<body onload="onBodyLoad()">
<div id="d1" style="visibility:hidden">
<button id="b1" onclick="js_find("ram")">Find it plz</button><br />
</div>
</body>
在find.js
:
var Find = function() {};
Find.prototype.func = function(funcname,funcdata) {
return cordova.exec(
null,
null,
'findPlugin',
funcname,
funcdata);
};
window.find = new Find();
function ws_find(name, param, callback){
if(undefined == callback){
var dataArray = [param, param, name];
}
else{
var dataArray = [callback, callback, name, param];
}
alert("Calling plugin function find with \r\n"+dataArray);
return window.find.func("find",dataArray);
}
行return window.find.func("find",dataArray);
被suppossed調用本地Java功能,但它給我上面的錯誤。