简体   繁体   中英

Why is my dojo modulePaths configuration being ignored?

I am trying to setup custom module paths in Dojo 1.6, however i cant seem to get the paths correct. I keep receiving the following error.. it seems like the path doesn't get changed..

Error

http://url/dojotest/dojo/myApp/base.js 404 (Not Found)

Directory Structure

/var/www/html/dojotest
   /dojo
      /dijit
      /dojo
      /dojox
   /myApp
      base.js
  index.html

index.html

<html>
<head>
   <title>Dojo Testing</title>
   <script src="dojo/dojo/dojo.js"></script>   
   <script>
   var djConfig = 
   {
      modulePaths : { 'myApp' : '../../myApp' }
   };
   dojo.require('myApp.base');
   </script>
</head>
<body>
   <div>Lala Testy test test</div>
</body>
</html>

base.js

dojo.provide('myApp.base');

console.log('you found me!');

You need to set the djConfig before including the dojo.js script tag

<script>
var dojoConfig = {
    modulePaths : { 'myApp' : '../../myApp' }
};
</script>

<script src="dojo/dojo/dojo.js"></script>

<script>
dojo.require('myApp.base');
</script>

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