Ext.container.Viewport:Viewport是一個容器,它會自動調(diào)整大小到整個瀏覽器窗口的大小。 然后,您可以在其中添加其他ExtJS UI組件和容器。
這里是創(chuàng)建Ext.container.Viewport容器的簡單語法。
Ext.create('Ext.container.Viewport', {
items: [child1, child2] // 這樣我們可以將不同的子元素作為容器項(xiàng)添加到容器中。
});
下面是一個簡單的例子顯示Ext.container.Viewport容器。
<!DOCTYPE html>
<html>
<head>
<link href="./ext-6.0.0/build/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet">
<script src="./ext-6.0.0/build/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>
這將產(chǎn)生以下結(jié)果 :
更多建議: