使用别名机制,一是可以解决引入名过长的问题,二是可以使用xtype类型。
代码
Language: JavaScript
Framework: ExtJS 4.1.1a
IDE: Excplise J2EE + Spket
1: Ext.define('Customer.support.SupportMessage', {
2: extend : 'Ext.panel.Panel',
3: alias : 'widget.supportMessage',
4: title : 'Customer Support',
5: html : 'Customer support is online'
6: });
7:
8: Ext.application({
9: name : 'Customer',
10: launch : function() {
11: Ext.create('Ext.container.Viewport', {
12: layout : 'fit',
13: items : [{
14: xtype : 'supportMessage'
15: }]
16: });
17: }
18: });
说明
- 我们可以在类的定义中,加入alias关键字,以启动别名机制;
- 当一个类使用alias进行别名处理之后,我们就可以使用对应的别名进行类的使用了;
- 使用类的别名时,必须使用widget.作为别名的前缀;
- 使用别名之后,我们就可以使用 xtype:'别名' 来进行类型的引用;