在Ember中set(this,'agentName','John')和this.set('agentName','John')之间有什

编程入门 行业动态 更新时间:2024-10-26 13:19:02
本文介绍了在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'

本文发布于:2023-10-29 02:52:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538517.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   set   Ember   John   agentName

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!