问题
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