在Ember中set(this,'agentName','John')和this.set('agentName','John')之间有什么区别? [英] What is the difference between set(this, 'agentName', 'John') and this.set('agentName', 'John') in Ember?
问题描述
对于get方法也是如此。像 get(this,'agentName')
和 this.get('agentName')
返回相同的值。 / p>
在官方 ember doc for get方法,它表明我们应该传递2个值来获取。那么 this.get('agentName')
如何准确地工作?
p> this.get(...)
是 Ember.get(this,...)的快捷方式
。但是,它仅在ember对象上可用,因此只有 Ember.get
可以在普通的js对象中使用。
看看 this.get(...)
实现。
The same is true for 'get' methods too. Like get(this, 'agentName')
and this.get('agentName')
returns the same value.
In the official ember doc for get method, it shows that we are supposed to pass 2 values to get. Then how does this.get('agentName')
work accurately?
this.get(...)
is a shortcut for Ember.get(this,...)
. However it is only available on ember objects, so only Ember.get
works in plain js objects.
Have a look at this.get(...)
implementation.
这篇关于在Ember中set(this,'agentName','John')和this.set('agentName','John')之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!