描述
Ext.container.Viewport:Viewport是一个容器,它会自动调整大小到整个浏览器窗口的大小。 然后,您可以在其中添加其他ExtJS UI组件和容器。句法
这里是创建Ext.container.Viewport容器的简单语法Ext.create('Ext.container.Viewport', { items: [child1, child2] // this way we can add differnt child elements to the container as container items. });
例
下面是一个简单的例子显示Ext.container.Viewport容器<!DOCTYPE HTML> <html> <head> <link href="Https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.CSS" rel="stylesheet" /> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script> <script type="text/javascript"> Ext.onReady(function () { var childPanel1 = Ext.create('Ext.panel.Panel', { title: 'Child Panel 1', html: 'A Panel' }); var childPanel2 = Ext.create('Ext.panel.Panel', { title: 'Child Panel 2', html: 'Another Panel' }); Ext.create('Ext.container.Viewport', { renderTo: Ext.getBody(), items: [ childPanel1, childPanel2 ] }); }); </script> </head> <body> </body> </html>
这将产生以下结果 :