var ChildView = Backbone.View.extend({
initialize : function (options) {
this.parent = options.parent;
}
});
// somewhere in the parent view ...
new ChildView({parent:this});
// You can use this code instead
var ChildView = Backbone.View.extend({
initialize : function (options) {
this._configure(options); // Set all the options as local variables
// This is used in the Backbone.View code on the latest version
}
});
2条答案
按热度按时间fjnneemd1#
在初始化步骤中,将
this
作为一个选项传递给子视图:eh57zj3b2#