使用骨干+骨干的Im, 当地Storage, 坚持我的数据,我的行为是错误的:
Ive got a model context with one Depende knownuser
Settings = Backbone.Model.extend({
localStorage : new Backbone.LocalStorage( settingsStore )
});
var settings = new Settings();
settings.set({user: USERNAME });
settings.save();
之后,如果我产生结果,就会出现这种情况。 我收到以下数据:
settings.attributes
Object
id: "3ac78cfb-ad60-1ab8-8391-f058ae9bfcfb"
user: "USERNAME"
__proto__: Object
Then I save the model to the localStorage, clear, and fetch it again:
settings.save();
settings.clear();
settings.fetch();
问题在于,如果我产生结果,情况就会随之而来。 属性现存于一个密封物体内:
settings.attributes
Object
0: Object
id: "3ac78cfb-ad60-1ab8-8391-f058ae9bfcfb"
user: "USERNAME"
__proto__: Object
__proto__: Object
And the problem is when I set the user name again in order to modify, a new attribute is added like this:
settings.attributes
Object
0: Object
id: "3ac78cfb-ad60-1ab8-8391-f058ae9bfcfb"
user: "USERNAME"
__proto__: Object
user: "NEWUSER"
__proto__: Object
而且,如果我拯救这一模式,我就再次从属性上获得2个新物体,并且每次都保持增长。