2011-07-29 67 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'