EmberJS一次设置多个属性 [英] EmberJS Set Multiple Properties At Once
本文介绍了EmberJS一次设置多个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过一系列设置调用设置大量属性,例如
I am setting lots of properties with a series of set calls e.g.
this.set('prop1', value1);
this.set('prop2', value2);
.......
有没有办法在一个电话(类似于当我创建一个对象)?例如:
Is there a way to do this in one call (similar to when I create an object)? E.g.
this.setMultiple({prop1: value1, prop2: value2});
我还没有完全了解Ember的继承模式。也许某些沿着重新开放的东西
?
I still don't fully grok Ember's inheritance model. Maybe something along the lines of reopen
?
推荐答案
为此功能: setProperties
。你可以这样使用:
There is actually a function for this: setProperties
. You can use it like this:
obj.setProperties({prop1: value1, prop2: value2})
obj
应该是 Ember的实例。对象
。
这篇关于EmberJS一次设置多个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文