Telephone + Js required

How can we use Phonegap with js requirement? I am trying to add to phonegap using the require () method. My code is below and all .js files are in the right place. Please help me, it can load the handset via AMD or use the usual script method, for example

<script type="text/javascript" src="cordova.js"></script> 

this is my configuration and methods

 require.config({ baseUrl: 'js/lib', paths: { controller: '../controller/controller', model: '../model/model', view: '../view/view', router:'../router/router' }, /* map: { '*': { 'tempName': 'actualName' } },*/ shim: { 'backbone': { deps: ['underscore', 'jquery','cordova'], exports: 'Backbone' }, 'underscore': { exports: '_' } } }); require(['jquery', 'backbone', 'router', ], function ($, Backbone, Router) { document.addEventListener('deviceready', function () { alert('hi'); // working navigator.notification.alert('hi'); // not working }, false); }); 
+6
source share
1 answer

Call and Phonegap tend to not work too well together.

The best way I've found is to simply include a cord script before your required modules.

 <script type="text/javascript" src="cordova-2.7.0.js"></script> <script data-main="js/main" src="require.js"></script> 

Mark the answer for this question . He gives a good idea of ​​some problems.

+8
source

Source: https://habr.com/ru/post/951624/


All Articles