extjs:什么是xtype好的 [英] extjs: what is xtype good for

查看:90
本文介绍了extjs:什么是xtype好的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到extjs中有很多例子,而不是实际创建extjs对象,一个带有xtype属性的对象文字被传入。



这是什么好东西对于?如果要创建对象,性能增益在哪里(如果是这个原因)?

解决方案

xtype是一个简写识别特定组件的方式:'panel'= Ext.Panel,'textfield'= Ext.form.TextField等。创建页面或窗体时,可以使用这些xtypes而不是实例化对象。例如,

  items:[{
xtype:'textfield',
autoWidth:true,
fieldLabel:'something'
}]

此外,以这种方式创建页面允许ExtJS 懒惰地页面。这是你看到表现获得的地方。而不是在应用程序加载时创建大量的组件,ExtJS会在用户需要查看组件时呈现组件。如果您有一个页面不是一件大事,但如果您利用标签页或手风琴,许多页面最初都会被隐藏,因此应用程序将加载更快。



此外,您可以创建并注册新组件,创建您选择的xtypes。 ExtJS将类似地渲染您的组件。



您还可以通过ID检索组件。由于您的组件(以及ExtJS组件)可能会提供一系列不错的行为,因此有时候方便搜索和检索组件,而不是简单的DOM元素或节点。


$ b $简而言之,xtypes识别组件和组件是ExtJS的一个关键方面。


I see there are lot's of examples in extjs where instead of actually creating extjs objects, an object literal with an xtype property is passed in.

What is this good for? Where is the performance gain (if that's the reason) if the object is going to be created anyway?

解决方案

xtype is a shorthand way to identify particular components: 'panel' = Ext.Panel, 'textfield' = Ext.form.TextField, etc. When you create a page or a form, you may use these xtypes rather than instantiate objects. For example,

items: [{
   xtype: 'textfield',
   autoWidth: true,
   fieldLabel: 'something'
}]

Moreover, creating pages in this manner allows ExtJS to render lazily the page. This is where you see a "performance gain." Instead of creating a large number of components when the app loads, ExtJS renders components when the user needs to see them. Not a big deal if you have one page, but if you exploit tabs or an accordion, many pages are initially hidden and therefore the app will load more quickly.

Furthermore, you may create and register new components creating xtypes of your choosing. ExtJS will similarly render your components lazily.

You may also retrieve components by ID. Since your component (as well as the ExtJS components) may provide a bunch of nice behavior, it is sometimes convenient to search for and retrieve a component rather than a simple DOM element or node.

In short, xtypes identify components and components are a key aspect of ExtJS.

这篇关于extjs:什么是xtype好的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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