1

Let's suppose I can access the following code:

http://localhost/web/src/js/myApp.js

Now I want to load myApp.js using requirejs from the javascript command line mode.

I did try the following but it does not work. Any ideas?

requirejs.config({
    baseUrl: "http://localhost/web/src/"
});

require("js/myApp"); // Error: Module name 'js/myApp' has not been loaded yet for context: _ http://requirejs.org/docs/errors.html#notloaded
4

1 に答える 1

1

That's because require('FILENAME') is used for loading already loaded files...i don't know what's the purpose behind it. You should use:

require(['module'], function(mod) {
    ... do some work ...

    // later, maybe if you want this (although, i don't understand why)
    require('module', function(m) {
        ... do some work with m - the new (or old?) module!
    })
});
于 2012-05-24T15:42:06.650 に答える