简体   繁体   English

无法“准备就绪”以在PhoneGap Build中工作

[英]Can't get 'deviceready' to work in PhoneGap Build

I have the following code in my app (Cordova CLI 5.2). 我的应用程序(Cordova CLI 5.2)中包含以下代码。

<script>  
  var onDeviceReady;

  onDeviceReady = function() {
    alert('device ready');
    document.body.style.backgroundColor = "red";
  };

  document.addEventListener('deviceready', onDeviceReady, false);
</script>

However I never see the alert (or background color change) on my Android after I build and install the app using PhoneGap Build. 但是,使用PhoneGap Build构建并安装应用程序后,我再也没有在Android上看到警报(或背景颜色变化)。 No matter what I do, I can't get this code to work. 无论我做什么,我都无法使此代码正常工作。

Okay. 好的。 I figured it out. 我想到了。 I wasn't including phonegap.js in index.html like this: 我没有像这样在index.html中包括phonegap.js:

<script src="phonegap.js"></script>

D'oh. 天啊

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM