我正在制作一个 requireJS/backbone/jquery 应用程序,我想知道我是否需要在每个脚本的这些全局库中都需要?
// App View
define(
[
'jquery',
'underscore',
'backbone'
],
function($, _, Backbone) {
var App = Backbone.View.extend( /* code here */ )
return App;
});
// and then later in my application:
// Router
define(
[
'jquery',
'underscore',
'backbone'
],
function($, _, Backbone) {
var Router = Backbone.Router.extend( /* code here */ )
return Router;
});
等等
或者一旦它们被加载到我的全局应用程序视图中,我可以忘记它们吗?我可以:
// App View
define(
[
'jquery',
'underscore',
'backbone'
],
function($, _, Backbone) {
var App = Backbone.View.extend( /* code here */ )
return App;
});
// and then later in my application:
// Router
define(
[],
function() {
var Router = Backbone.Router.extend( /* code here */ )
return Router;
});