alternateClassNames 的用途是什么

发布于 2024-11-30 05:23:08 字数 276 浏览 1 评论 0原文

因此,int ExtJS 我们有:

  • “真正的”类型名称(在Ext.define 中作为第一个参数的名称)
  • aliasalternateClassName
  • xtype

对我来说最神秘的是alternateClassName 如果我们已经拥有如此丰富的类型描述符,为什么我们还需要它们呢? 请注意,我并不是想讨论意识形态方法的质量。 问题只是关于为什么要实施这一点以及到底出于什么目的。

So, int ExtJS we have:

  • "real" type name (that one that goes as first param in Ext.define)
  • alias
  • alternateClassName
  • xtype

The most enigmatic to me is alternateClassName.
Why do we actually need them if we already have such a zoo of type descriptors?
Note that I'm not trying to discuss the quality of the ideological approach.
The question is only about why this was implemented and for what exactly purposes for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

樱&纷飞 2024-12-07 05:23:08

它们用于向后兼容。例如,ExtJS 4中的Ext.grid.Panel

alternateClassName: ['Ext.list.ListView', 'Ext.ListView', 'Ext.grid.GridPanel']

因为它取代了ListView而被命名为Ext.grid.GridPanel。

They're used for backwards-compatibility. For example, Ext.grid.Panel in ExtJS 4 has

alternateClassName: ['Ext.list.ListView', 'Ext.ListView', 'Ext.grid.GridPanel']

because it replaces ListView and used to be named Ext.grid.GridPanel.

故事未完 2024-12-07 05:23:08

据我所知,alternateClassName 有助于调用具有不同名称的类,我们可以根据类名使用操作。

下面的代码将对您有所帮助:

Ext.define('Sample', {    
    alternateClassName: ['Example', 'Important'],     
    code: function(msg) {        
        alert('Sample for alternateClassName... ' + msg);     
    },
    renderTo :document.body
});
var hi = Ext.create('Sample');
hi.code('Sample');
var hello = Ext.create('Example');
hello.code('Example');
var imp = Ext.create('Important');
imp.code('Important');

在上面的代码中,您可以找到如下内容:

1.我们为一个类使用三个名称,分别为 Sample、Example、Important。
2.我们可以根据类名使用动作,即警报消息。
3.我们根据类名显示警报消息。这里我们显示警报消息以显示结果。但是我们可以根据类名编写一些操作,例如,如果我们想创建一个按钮,我们需要根据类名在按钮上编写操作,这会很有帮助。

您可以在下面找到工作示例:

http://jsfiddle.net/kesamkiran/kVbra/30/

As per i know alternateClassName is helpful to call one class with diffrent names and we can use the actions as per class name.

The below code will be helpful for you:

Ext.define('Sample', {    
    alternateClassName: ['Example', 'Important'],     
    code: function(msg) {        
        alert('Sample for alternateClassName... ' + msg);     
    },
    renderTo :document.body
});
var hi = Ext.create('Sample');
hi.code('Sample');
var hello = Ext.create('Example');
hello.code('Example');
var imp = Ext.create('Important');
imp.code('Important');

In the above code,you can find the things like:

1.We are using three names called Sample,Example,Important for one class.
2.We can use the action i.e., alert message according to the class name.
3.We are displaying the alert message based on the class name.Here we are displaying the alert message for showing the result.But we can write some actions according to the class name like,if we want to create one button and we need to write action on the button as per class name then this will be helpful.

You can fint the working sample below:

http://jsfiddle.net/kesamkiran/kVbra/30/

美人迟暮 2024-12-07 05:23:08

别名

别名由命名空间和由句点连接的名称组成,如 [namespace].[name]

由于命名空间的原因,其使用仅限于上下文,例如 widget、store、controller 等(例如,对于控制器派生类,您可以使用“controller.foo”等别名,现在在将控制器附加到视图时只能使用“foo”名称)

xtype

仅适用于 Ext.Component派生类

在定义视图时很有用,因为您可以编写 代码

alternateClassName

比上面两个更通用的 更少。您可以将其用于实用程序类,因此不必引用整个命名空间

对于用于存储声明为app.util.navigationConstants的常量的单例类,您可以定义一个备用类名更短的是 NavConsts。现在您可以使用 NavConsts.CONST_NAME 而不是 app.util.navigationConstants.CONST_NAME

alias

An alias consists of a namespace and a name concatenated by a period as [namespace].[name]

Because of the namespace, its usage is restricted to context, e.g. widget, store, controller, etc (e.g. for a controller derived class you can use an alias like "controller.foo", and you can now use only "foo" name when attaching the controller to a view)

xtype

Only applies to Ext.Component derived classes

Useful when defining views because you write less code

alternateClassName

more general purpose than above two. you can use this for your utility classes, so you don't have to reference the whole namespace

For a singleton class used for storing constants declared as app.util.navigationConstants, you can define an alternate class name that is shorter, NavConsts. And you could now use NavConsts.CONST_NAME instead of app.util.navigationConstants.CONST_NAME

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文