Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有另一个嵌套对象的对象,我想使用 Backbone 的 .get() 功能对其进行修改。根据文档,我可以设置根级对象键,但是有没有办法改变嵌套属性?
您可以设置/获取嵌套值,但它将充当替换而不是更新。
model = {'foo': {'bar': 'baz', 'qux': 'foo'}}; model.get('foo'); // {'bar': 'baz', 'qux': 'foo'} model.set('foo', {'baz': 'qux'}); model.get('foo'); // {'baz': 'qux'}