我知道requireJS支持糖语法,以下代码是否正确加载位于js/window/startup.js的模块,具有jquery、下划线和Backbone的依赖关系?
require.config({
baseUrl: 'http://localhost/js/',
path: {
jquery: '/lib/jquery-1.9.1.min',
underscore: '/lib/underscore-1.4.4',
backbone: '/lib/backbone-1.0'
}
});
require([
'./window/startup',
'jquery',
'underscore',
'backbone',
], function(Startup){
Startup.init();
});
js/window/startup.js 中的代码:
define(function (require) {
var $ = require('jquery');
_ = require('underscore');
Backbone = require('backbone');
//Test to see if module is being fired
console.log('The module code has been executed!');
var init = function(){
/* SOME CODE */
//Test to see if the init function has fired
console.log('The initialize function has fired!');
}
return {
init: init
}
});
这一切似乎都符合文档,但是当我运行这段代码时,两个控制台消息都没有显示。