阅读背景:

Backbone.Models this.get()复制整个数组或指向内存中的同一个数组

来源:互联网 
 Person = Backbone.Model.extend({
        defaults: {
            name: 'Fetus',
            age: 0,
            children: []
        },
        initialize: function(){
            alert("Welcome to this world");
        },
        adopt: function( newChildsName ){
            var children_array = this.get("children");
            children_array.push( newChildsName );
            this.set({ children: children_array });
        }
    });

    var person = new Person({ name: "Thomas", age: 67, children: ['Ryan']});
    person.adopt('John Resig');
    var children = person.get("children"); // ['Ryan', 'John Resig']
 Person = Backbone.Model.extend({
        defau



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: