动态添加项目到边框视口 [英] dynamic add items to border viewport
问题描述
我想先创建一个空的视口(layout:border),然后添加项目,最后渲染和显示。
但是当我创建了viewport元素时,会抛出一个错误,说:
I want to create a empty viewport(layout:border) first, then add items to it, finally render and show. but when I created the viewport element, it throw an error, says:
未捕获TypeError:无法读取属性flex未定义
Uncaught TypeError: Cannot read property 'flex' of undefined
这是我的代码:
<script type="text/javascript" src="ext-4.0.2a/bootstrap.js"></script>
<script>
Ext.require(['*']);
Ext.onReady(function() {
Ext.QuickTips.init();
var viewport = Ext.create('Ext.container.Viewport', {
layout: 'border'
});
var north = blablabla...
viewport.add([north,south]);
viewport.doLayout();
});
</script>
推荐答案
根据从 docs :
BorderLayout的区域在渲染时固定,此后,其子组件可能无法删除或添加。要在BorderLayout中添加/删除组件,请它们由一个由BorderLayout直接管理的附加容器包裹。
The regions of a BorderLayout are fixed at render time and thereafter, its child Components may not be removed or added.To add/remove Components within a BorderLayout, have them wrapped by an additional Container which is directly managed by the BorderLayout.
顺便说一下
任何使用边框布局的容器必须有一个子项,区域为:'center'
Any Container using the Border layout must have a child item with region:'center'
这篇关于动态添加项目到边框视口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!