简体   繁体   中英

cordova is not defined - cordova.js has already been loaded :: Ionic

During the app running, this is what I get:

Uncaught ReferenceError: cordova is not defined
ionic-core.js:466 Ionic Core: init
ionic-core.js:145 Ionic Core: searching for cordova.js
ionic-core.js:149 Ionic Core: cordova.js has already been loaded

Now this is making me confused but I assume that Ionic is trying to load cordova before it is defined. However, this prevents me from using other services that rely on this condition, so my question is, is there a way to load cordova async or what else might be my problem?

index.html

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/angular-websocket/angular-websocket.js"></script>
<script src="lib/ionic-service-core/ionic-core.js"></script>
<script src="lib/ionic-service-push/ionic-push.js"></script>
<script src="lib/facebook-connect-plugin/index.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script src="js/utils.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
<script src="cordova.js"></script>

ng-cordova uses cordova so it must be loaded later:

<script src="cordova.js"></script>
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>

cordova's plugin is designed for native plaform. So running ionic in a browser will fail all the plugins. That's the story.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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