【问题标题】:Ripple + Phonegap - deviceready not firingRipple + Phonegap - deviceready 没有触发
【发布时间】: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 事件监听器。这个技巧对我有用。

标签: cordova ripple


【解决方案1】:

搞定了。我从

复制了 cordova.js 和 cordova_plugins.js
[APP-DIR]\platforms\android\assets\www

进入

[APP-DIR]\www

这解决了两个 js 文件上的 404 问题。然后这两个都在我的 custom.js 文件中工作以捕获 deviceready 事件。

document.addEventListener("deviceready", function(){
        console.log("Device Ready!!!");
 },true);


document.addEventListener("deviceready", callMe, false);

function callMe() {
    // Now safe to use the Cordova API
    console.log("Call ME!");
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多