2011-07-29 68 views
3

我想创建一个空的视窗(布局:边框),然后再添加项目,最终呈现和表演。 但是当我创建的视口的元素,它抛出一个错误,说:动态添加项目边界视

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> 

回答

7

据到从docs做笔记:

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.

顺便说一句

Any Container using the Border layout must have a child item with region:'center'