alternateClassNames 的用途是什么
因此,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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它们用于向后兼容。例如,ExtJS 4中的Ext.grid.Panel
因为它取代了ListView而被命名为Ext.grid.GridPanel。
They're used for backwards-compatibility. For example, Ext.grid.Panel in ExtJS 4 has
because it replaces ListView and used to be named Ext.grid.GridPanel.
据我所知,alternateClassName 有助于调用具有不同名称的类,我们可以根据类名使用操作。
下面的代码将对您有所帮助:
在上面的代码中,您可以找到如下内容:
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:
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/
别名
别名由命名空间和由句点连接的名称组成,如 [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