我第一次开始使用PhoneGap应用程序,我想知道如何检测 cordova.js 中的代码何时完成处理。我已经搜索了不少但没有遇到这么简单的答案,所以我想知道我是否真的正在搜索。
例如,当我在浏览器中测试应用程序时,会出现PhoneGap启动页面,并且在它消失之前会有暂停。当我删除 cordova.js 的加载时,这显然不会发生。但是,我确实想使用 cordova.js 。
所以,问题是如何检测暂停何时结束?
答案 0 :(得分:1)
首先通过查看SplashScreenDelay
中config.xml
的值来确定您的初始屏幕显示的时间
必须是像流动的东西
<preference name="SplashScreenDelay" value="3000" />
如果config.xml
中不包含首选项,则可以添加它。
一旦你知道SplashScreenDelay
在setTimeOut
事件中为该时间段添加deviceready
喜欢以下
function onDeviceReady(){
console.log("Cordova/device is ready");
//do further tasks.
}
document.addEventListener("deviceready", function(){
setTimeOut(onDeviceReady,3000) // 3000 is ms set in preference earlier in config.xml
}, false);