我正在使用 require.js,并在我的配置文件中调用以下命令来启动应用程序(使用此页面作为参考:http ://backbonetutorials.com/organizing-backbone-using-modules/ ):
require(['backbone', 'jquery', 'app'], function(Backbone, $, App) {
console.log('no dependancies loaded');
});
但是,当它遵守(通过 grunt.js)时,它不会加载主干和 jquery - 它甚至没有列出任何依赖项。但是,如果我删除应用程序需要主干并加载 jquery,例如:
require(['backbone', 'jquery'], function(Backbone, $) {
console.log('dependancies loaded');
});
main.js
require.config({
paths: {
jquery: 'vendor/jquery',
underscore: 'vendor/underscore',
backbone: 'vendor/backbone'
},
shim: {
jquery: [],
backbone: {
deps: ['vendor/underscore', 'vendor/jquery'],
exports: 'Backbone'
},
underscore: {
exports: '_'
}
}
});
require(['backbone', 'jquery', 'App'], function(Backbone, $, App) {
App.initialize();
});
应用程序.js
define(['jquery', 'underscore', 'backbone', 'router'], function($, _, Backbone, Router){
var initialize = function() {
// Pass in our Router module and call it's initialize function
Router.initialize();
};
return {
initialize: initialize
};
});
不显示错误消息。为什么它不接他们?