不,查看方法不使用此選項。 model
和collection
將成爲View對象的屬性。 從源代碼引用:
// List of view options to be merged as properties.
var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName'];
// Set up all inheritable **Backbone.View** properties and methods.
_.extend(View.prototype, Events, {
...
// Performs the initial configuration of a View with a set of options.
// Keys with special meaning *(model, collection, id, className)*, are
// attached directly to the view.
_configure: function(options) {
if (this.options) options = _.extend({}, this.options, options);
for (var i = 0, l = viewOptions.length; i < l; i++) {
var attr = viewOptions[i];
if (options[attr]) this[attr] = options[attr];
}
this.options = options;
},
...
};
如果是這樣,那麼他們真的不是那麼特別,那麼他們是允許添加到視圖的屬性的限制列表?嗯,那很傷心。我認爲他們有更多的魔力。 – Henry
@Henry:骨幹本身對視圖的「模型」和「集合」做的不多,但擴展(如[Marionette](https://github.com/derickbailey/backbone.marionette))可以利用具有一致接口的每個模型和每個集合視圖的約定。 –