cordova: how to call method after all modules are loaded

六月ゝ 毕业季﹏ 提交于 2019-12-13 00:41:50

问题


I am using Cordova and I'm using some plugins too. So now I want to do the task after all of the plugins/modules are loaded. How to achieve this in Cordova? Does Cordova provide any callback after the plugins are loaded?

I have used onload but now i want some alternate to it. Is there some callback provided by Cordova to be called after all modules are loaded.


回答1:


You can use deviceready. Check out the example ....

<!DOCTYPE html>
<html>
  <head>
    <title>Device Ready Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    function onDeviceReady() {
        // Now safe to use device APIs
    }

    </script>
  </head>
  <body onload="onLoad()">
  </body>
</html>

... from the documentation.



来源:https://stackoverflow.com/questions/28995048/cordova-how-to-call-method-after-all-modules-are-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!