我有三大骨幹View類繼承:骨幹觀的繼承 - 調用父導致遞歸
var preventRecursion = 0;
var parentView = Backbone.View.extend({
initialize: function(){
console.log('parentView');
}
});
var nestedChildView = parentView.extend({
initialize: function(){
if (++preventRecursion == 5) {throw "Recursion"};
console.log('nestedChildView');
this.constructor.__super__.initialize.apply(this);
}
});
var nestedNestedChildView = nestedChildView.extend({
initialize: function(){
console.log('nestedNestedChildView');
this.constructor.__super__.initialize.apply(this);
}
});
當我嘗試創建nestedNestedChildView:
var t = new nestedNestedChildView();
我得到無限遞歸: 這裏是jsfiddle
謝謝你的回答。 – Erik