我已经为cordova安装了diaglog插件。当我运行它时,出现一个错误,提示“无法调用未定义的方法'alert'”。
当我从控制台执行相同的功能时,它可以完美运行。
这是我的index.html文件:
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="plugins/org.apache.cordova.dialogs/www/notification.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
navigator.notification.alert( <--------------------- here!!
'You are the winner!', // message
function(){
}, // callback
'Game Over', // title
'Done' // buttonName
);
});
</script>
<LINK rel="stylesheet" href="style.css" type="text/css">
</head>
<body >
<div> hello world</div>
</body>
</html>
最佳答案
您将需要等待DeviceReady Event。
插件未在中初始化
$(document).ready();
文档已加载->文档准备就绪-> cordova开始初始化-> deviceready