define(['module/first'], function (firstModule) {
//Module code with a dependency on module/first goes here.
});
The alternate define "syntax":<script data-main="app/config" src="assets/js/libs/require.js"></script>
file: config.js:require.config({
paths: {
jquery: '../assets/js/libs/jquery'
}
});
require(['app']);
file: app.js:define(function(require) {
var FirstModule = require('modules/first');
//Module code with a dependency on module/first goes here.
@reference_1_stackoverflow
Why use alternate requirejs define: define(function(require) { … }
@reference_2_stackoverflow
RequireJS: require a module return a function instead of a object
@reference_3_requirejs.org
Define a Module as a Function
No comments:
Post a Comment