我有一个三个 Backbone 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