I have a js file that is simply just using the dojo provide statement to give the namespace for an object. Its a simple settings file that will be referenced for settings throughout the application. So Instead of creating a class (module) specifically for these properties I thought I would just give it a name space and reference that in my app js file.
Here is what I have
dojo.provide('app');
dojo.require('settings');
dojo.ready(function(){
console.log("settings = ", settings.obj.prop1);
});
Then in my settings.js
dojo.provide('settings');
var obj = {
prop1:'property 1',
prop2:'http://fdsfsdfs'
}
console.log("settings module loaded");
When I use required in my app.js it shows me the 开发者_如何学运维settings.js has loaded as the console trace shows me its loaded. But when I try to do a trace on the obj that is inside of settings its saying undefined.
You are defining a global variable obj. You should define inside settings, where you want it
settings.obj = { ... };
instead of
var obj = { ... }
精彩评论