Extjs4,创建Ext组件有了新的方式,就是Ext.create(....),而且可以使用动态加载JS的方式来加快组件的渲染,我们再也不必一次加载已经达到1MB的ext-all.js了,本文介绍如何在EXTJS4中创建一个window。
注:代码中所有Ext.Window应该是Ext.window.Window,如果按Ext.Window的话,在某些浏览器中显示不出Window窗口,切记。。。。
代码如下:
- <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <htmlxmlns="http://www.w3.org/1999/xhtml">
- <head>
- <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
- <title>窗口实例</title>
- <linkrel="stylesheet"type="text/css"href="../../resources/css/ext-all.css"/>
- <scripttype="text/javascript"src="../../bootstrap.js"></script>
- <scripttype="text/javascript"src="../../locale/ext-lang-zh_CN.js"></script>
- <scripttype="text/jscript">
- Ext.require('Ext.window');
- Ext.onReady(function(){
- Ext.create('Ext.Window',{
- width:400,
- height:230,
- //X,Y标识窗口相对于父窗口的偏移值。
- x:10,
- y:10,
- plain:true,
- //指示标题头的位置,分别为top,bottom,left,right,默认为top
- headerPosition:'left',
- title:'ExtJS4Window的创建,头在左'
- }).show();
- Ext.create('Ext.Window',{
- width:400,
- height:230,
- x:500,
- y:10,
- plain:true,
- //指示标题头的位置,分别为top,bottom,left,right,默认为top
- headerPosition:'right',
- title:'ExtJS4Window的创建,头在右'
- }).show();
- Ext.create('Ext.Window',{
- width:400,
- height:230,
- x:10,
- y:300,
- plain:true,
- //指示标题头的位置,分别为top,bottom,left,right,默认为top
- headerPosition:'bottom',
- title:'ExtJS4Window的创建,头在底'
- }).show();
- varwin=Ext.create('Ext.Window',{
- width:400,
- height:230,
- x:500,
- y:300,
- plain:true,
- //指示标题头的位置,分别为top,bottom,left,right,默认为top
- headerPosition:'top',
- title:'ExtJS4Window的创建'
- });
- win.show();
- });
- </script>
- </head>
-
- <body>
- </body>
- </html>
本文介绍如何在EXTJS4中利用Ext.create()方法创建窗口组件,并通过动态加载JS来提高渲染速度,避免了一次加载庞大的ext-all.js文件。通过示例代码展示了窗口的不同布局和位置设置。
621

被折叠的 条评论
为什么被折叠?



