anchor
和fit
layout in有ExtJs 5
什么区别?
锚点类似于vbox布局,但是它允许您确定子项的宽度和高度。
适合的布局,仅使具有此布局的组件的子代具有与其父代相同的大小。
所以:
Ext.create('Ext.Panel', {
width: 500,
height: 500,
layout: 'anchor',
items: [
{
xtype: 'panel',
title: '10% height and 20% width',
anchor: '10% 20%'
},
{
xtype: 'panel',
title: '30% height and 50% width',
anchor: '30% 50%'
}
]
});
在此示例中,您将拥有一个尺寸为500x500的面板,其中包括两个子面板,其中一个子面板为50x100,而另一个子面板为150x250。两者都向左对齐。父面板的其余部分将为空。这是小提琴:https : //fiddle.sencha.com/#fiddle/i4r
适合:
Ext.create('Ext.Panel', {
width: 500,
height: 500,
layout: 'fit',
renderTo: Ext.getBody(),
title: 'Fit Layout',
items: [{
xtype: 'panel',
border:true,
title: 'Children of fit layout'
}]
});
在这种情况下,子面板的尺寸将与其父面板的尺寸相同,为500x500。这是小提琴:https : //fiddle.sencha.com/#fiddle/i4s
根据评论进行编辑:请注意,“适合”可以有一个,只有一个孩子
希望很清楚。关键是这两种布局打算在不同情况下使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句