在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?

查看:104
本文介绍了在Ember中set(this,'agentName','John')和this.set('agentName','John')之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆