Ext.container.Viewport
优质
小牛编辑
132浏览
2023-12-01
Ext.container.Viewport - Viewport是一个容器,可以自动调整自身大小到整个浏览器窗口的大小。 然后,您可以在其中添加其他ExtJS UI组件和容器。
语法 (Syntax)
以下是创建Ext.container.Viewport容器的简单语法。
Ext.create('Ext.container.Viewport', {
items: [child1, child2]
// this way we can add different child elements to the container as container items.
});
例子 (Example)
以下是显示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>