1
var TestView = Backbone.View.extend({
options: {
"theList": []
},
initialize: function() {
console.log(this.options.theList.length);
this.options.theList.push("xxx");
}
});
// other place:
var view1 = new TestView();
// the console result will be 0
var view2 = new TestView();
// the console result will be 1 !!!
var view3 = new TestView();
// the console result will be 2 !!!!!!
...骨干
为什么视野中的其他附加变量?我认为它会每次只是我0 new
TestView
!
相当不错,我真的很感谢你的回答! – Liber
但我在Chrome中控制视图,'option'属性不放置在__proto__属性中,它只是在那里。 – Liber
@Liber:你看错了地方:http://jsfiddle.net/ambiguous/T24Rz/ –