简体   繁体   English

未捕获的TypeError:对象#<Object>在file:///android_asset/www/index.html上没有方法'exec'

[英]Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/index.html

  • using PhoenGap 2.2.0 使用PhoenGap 2.2.0
  • Executed \\bin\\create C:\\Temp\\Test com.test Test 执行\\ bin \\ create C:\\ Temp \\ Test com.test测试
  • Had following output 有以下输出

Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. Microsoft(R)Windows脚本宿主版本5.8版权所有(C)Microsoft Corporation。 All rights reserved. 版权所有。

Creating new android project...
Building jar and js files...
Copying template files...
Copying js, jar & config.xml files...
Copying cordova command tools...
Updating AndroidManifest.xml and Main Activity...
  • Imported Project 进口项目
    • On eclipse (4.2.0) did 在eclipse(4.2.0)上做了
    • File > New > Project > Android > Android Project from Existing Code 文件>新建>项目> Android>现有代码中的Android项目
    • Selected the folder C:\\Temp\\Test 选择文件夹C:\\ Temp \\ Test
    • Checked "Copy project into workspace" 选中“将项目复制到工作区”
  • Making changes 做出改变
    • Checked res\\xml\\config.xml and the line <plugin name="Notification" value="org.apache.cordova.Notification"/> is present 检查res \\ xml \\ config.xml并且行<plugin name="Notification" value="org.apache.cordova.Notification"/>存在
    • Checked that index.html has the cordova-2.2.0.js included 检查index.html是否包含cordova-2.2.0.js
    • Case#1 Opened index.html and modified from 案例#1打开index.html并修改自

<script type="text/javascript"> app.initialize(); </script>

to

<script type="text/javascript">
function showAlert(msg){
navigator.notification.alert(msg);
}
document.addEventListener("deviceready", showAlert('You are the winner!'), false);
app.initialize();
</script>

I get following error 11-25 10:29:58.399: E/Web Console(14604): Uncaught TypeError: Cannot call method 'alert' of undefined at file:///android_asset/www/index.html:40 我得到以下错误11-25 10:29:58.399: E/Web Console(14604): Uncaught TypeError: Cannot call method 'alert' of undefined at file:///android_asset/www/index.html:40

    • Case#2 Opened index.html and modified from 案例#2打开index.html并修改自

<script type="text/javascript"> app.initialize(); </script>

to

<script type="text/javascript">
function successAlert(){}
function errorAlert(){}
function showAlert(msg){
cordova.exec(successAlert, errorAlert, "Notification","alert", [msg]);
}
document.addEventListener("deviceready", showAlert('You are the winner!'), false);
app.initialize();
</script>

I get following error 11-25 10:25:06.575: E/Web Console(14149): Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/index.html:42 } 我收到以下错误11-25 10:25:06.575: E/Web Console(14149): Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/index.html:42 }

I'm sure that I missed something...just that I'm not able to conclude what is it. 我确信我错过了一些东西......只是因为我无法得出结论。 Please help me out. 请帮帮我。

This will call showAlert immediately, instead of delaying to when the event fires: 这将立即调用showAlert ,而不是在事件触发时延迟:

document.addEventListener("deviceready", showAlert('You are the winner!'), false)

Instead do this 而是这样做

document.addEventListener("deviceready", function() {
    showAlert('You are the winner!')
}, false)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Phonegap:对象xx在文件中没有方法&#39;exec&#39;:///android_asset/www/cordova.js - Phonegap: Object xx has no method 'exec' at file:///android_asset/www/cordova.js 未捕获的ReferenceError:在文件:///android_asset/www/index.html:27上未定义show_pic - Uncaught ReferenceError: show_pic is not defined at file:///android_asset/www/index.html:27 LeafLet错误:对象# <Object> 在file:///android_asset/www/leaflet.js:6没有方法&#39;onAdd&#39; - LeafLet Error : Object #<Object> has no method 'onAdd' at file:///android_asset/www/leaflet.js:6 在phonegap中的file://android_asset/www/index.html上未定义函数 - function is not defined at file://android_asset/www/index.html in phonegap 应用程序错误是一个目录(file:///#android_asset/www/index.html) - Application Error Is a directory (file:///#android_asset/www/index.html) 与服务器的连接不成功。(file:///android_asset/www/index.html) - The connection to the server was unsuccessful.(file:///android_asset/www/index.html) Reactjs-router-dom和cordova始终直接指向file:///android_asset/www/index.html - Reactjs-router-dom and cordova always direct to file:///android_asset/www/index.html 未捕获的TypeError:无法读取未定义的属性&#39;OneSignal&#39;,来源:file:/// android_asset / www / js / app - Uncaught TypeError: Cannot read property 'OneSignal' of undefined", source: file:///android_asset/www/js/app 未捕获的TypeError:对象没有方法&#39;exec&#39; - Uncaught TypeError: Object has no method 'exec' Android WebView未捕获的TypeError:对象[object Object]没有方法 - Android WebView Uncaught TypeError: Object [object Object] has no method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM