【发布时间】:2014-12-27 02:16:51
【问题描述】:
刚刚使用 npm install 在 Windows7 上安装了最新版本的 phonegap 和ipple。
我从我的项目目录运行涟漪模拟以在 Chrome 中启动涟漪。
http://localhost:4400/?enableripple=cordova-3.0.0
但是我得到了一个在 cordova.js 上找不到的文件,并且我的 deviceready 事件没有触发。
GET http://localhost:4400/cordova.js 404 (Not Found)
项目正在运行带有 jquery 1.11.1 的 jquery mobile 1.4.4。
这就是我的 js 在页脚中的样子。我该如何解决这个问题并让我的 deviceready 事件触发?
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="css/vendor/jquery-mobile/jquery.mobile-1.4.4.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
使用以下 js 测试设备就绪。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
// Now safe to use the Cordova API
console.log("Device Ready");
}
【问题讨论】:
-
尝试仅在
index.html中调用deviceready事件监听器。这个技巧对我有用。