dojo 1.9:declare.safeMixin添加什么注释? [英] dojo 1.9: what annotation does declare.safeMixin add?

查看:390
本文介绍了dojo 1.9:declare.safeMixin添加什么注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关 dojo 1.9 文档参考指南/ 1.9 / dojo / _base / declare.html#safemixinrel =nofollow> declare.safeMixin() ,重点介绍它和 lang .mixin

I have been reading through the dojo 1.9 documentation about declare.safeMixin(), focusing on the difference between it and lang.mixin.

这是我发现的解释...

Here is the explanation I found...


safeMixin()是一个在dojo / declare中定义的函数。它具有与dojo / _base / lang :: mixin()相同的功能,但另外它与dojo / declare兼容地注释所有复制的方法。这种装饰可以影响如何使用in.inherited()在混合方法中工作。

safeMixin() is a function defined in dojo/declare. It has the same functionality as dojo/_base/lang::mixin(), but additionally it annotates all copied methods compatibly with dojo/declare. This decoration can affect how this.inherited() works in mixed-in methods.

我可以按照示例,但它并不真正解释什么是添加什么,哪里可以任何人再给出每个复制方法添加什么注释的例子?

I can follow the example but it doesn't really explain exactly what is added and where, can anyone give any further examples of what annotation is added to each copied method?

所以要清楚,我不是要求对继承的解释,我只是问特别是关于使用 declare.safeMixin()而不是 lang.mixin 添加的注释。

So to be clear, I'm not asking for an explanation of inheritance, I'm just asking specifically about the annotations added by using declare.safeMixin() instead of lang.mixin.

推荐答案

safeMixin 添加 nom 到与目标混合的功能。该属性设置为从函数分配到的源对象的键。例如如果您调用 declare.safeMixin(target,{foo:function(){}}) nom 该功能是foo。这对于 this.inherited(arguments)来说是必要的,以自动找出它应该调用父foo。使用 safeMixin 的替代方法是明确指定父函数的名称: this.inherited('foo',arguments);

safeMixin adds the nom property to functions that are mixed in to the target. This property is set to the key from the source object that the function was assigned to. e.g. if you call declare.safeMixin(target, { foo: function() {} }), the nom property for that function is "foo". This is necessary for this.inherited(arguments) to automatically figure out that it should call the parent "foo". The alternative to using safeMixin would be to explicitly specify the name of the parent function: this.inherited('foo', arguments);.

这篇关于dojo 1.9:declare.safeMixin添加什么注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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