[英]Phonegap: Object xx has no method 'exec' at file:///android_asset/www/cordova.js
[英]Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/index.html
Microsoft(R)Windows脚本宿主版本5.8版权所有(C)Microsoft Corporation。 版权所有。
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...
<plugin name="Notification" value="org.apache.cordova.Notification"/>
存在 <script type="text/javascript"> app.initialize(); </script>
至
<script type="text/javascript">
function showAlert(msg){
navigator.notification.alert(msg);
}
document.addEventListener("deviceready", showAlert('You are the winner!'), false);
app.initialize();
</script>
我得到以下错误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
<script type="text/javascript"> app.initialize(); </script>
至
<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>
我收到以下错误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
}
我确信我错过了一些东西......只是因为我无法得出结论。 请帮帮我。
这将立即调用showAlert
,而不是在事件触发时延迟:
document.addEventListener("deviceready", showAlert('You are the winner!'), false)
而是这样做
document.addEventListener("deviceready", function() {
showAlert('You are the winner!')
}, false)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.