首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

Extjs xtype 深入懂得

2012-11-23 
Extjs xtype 深入了解做Extjs有一段时间了,遇到了各种问题,现在我对xtype 做一下总结和基本的说明?xtype

Extjs xtype 深入了解

做Extjs有一段时间了,遇到了各种问题,现在我对xtype 做一下总结和基本的说明

?

xtype 就是Extjs 用于创建对象的一种形式

?

就比如xtype:'button' 就会创建Button对象似的

?

但这些xtype是谁来管理的,在看了源代码和大量实践后,发现

?

?

create: function(component, defaultType){        if (component instanceof Ext.AbstractComponent) {            return component;        }        else if (Ext.isString(component)) {            return Ext.createByAlias('widget.' + component);        }        else {            var type = component.xtype || defaultType,                config = component;                        return Ext.createByAlias('widget.' + type, config);        }    },
?

1.内存节约

2.加快browser运行速度

?

其实可以这样说,这种方式就是延迟实例化

?

很明了吧

?

extjs的工作基本流程是

?

1.实例化

2.渲染

3.显示

?

上面xtype延迟实例化

那么可以想象,如果你用Ext.create或者new对象的形式,创建extjs component 那么

xtype的属性是在上面定义的组件显示的时候才会被创建然后渲染,显示。

?

这就是很多人不明白的extjs 组件创建流程

?

?

热点排行