我需要一個視圖需要骨幹,Undescore和jQuery等骨幹與requirejs:查看和子視圖和r.js
例如
define(['jquery','undescore','backbone','subviewA', 'subviewB'], function($,_,Backbone, SubviewA, SubviewB){
var View = Backbone.View.extend({
//other methods here
render : function() {
this.subviewA = new SubviewA();
this.subviewA.render();
this.subviewB = new SubviewB();
this.subviewB.render();
return this;
}
});
});
子視圖例如
define(['jquery','undescore','backbone','text!templates/subviewA'], function($,_,Backbone, template){
var SubviewA = Backbone.View.extend({
//other methods here
render : function() {
this.$el.html(template);
return this;
}
});
});
我問題是如果我需要在子視圖中包含jquery,exccore和backbone,我可以省略它們嗎?
編輯
我要求在r.js因爲我需要每次都告訴它不要biuld每個模塊內部的依賴關係。
您可以粘貼您的某個'SubView'模塊的代碼嗎?您應該能夠像上面那樣列出依賴關係。 – JonnyReeves
你不需要在這個視圖中使用jquery和下劃線,但可能需要在你的子視圖中至少使用jquery。一般來說,你需要一個你在該模型或視圖中直接使用的東西的要求 – Krym