这是我的分机号
Ext.create('Ext.panel.Panel', {
title: 'Customer Information',
width: 300,
bodyPadding: 5,
floating: true,
renderTo: document.body,
frame: true,
collapsible: true,
closable: true,
defaults: { labelWidth: 90 },
items: [{
xtype: 'image',
id: 'profile_pic',
name: 'profile_pic',
style: { display: 'block', margin: 'auto' },
src: 'http://www.sencha.com/img/20110215-feat-html5.png',
},{
xtype: 'displayfield',
fieldLabel: 'ID',
name: 'viewer_id',
id: 'viewer_id',
padding: '5 0 0 0',
fieldCls: 'specialfield',
value: ''
},{
xtype: 'displayfield',
fieldLabel: 'Name',
name: 'viewer_name',
id: 'viewer_name',
fieldCls: 'fieldcolor',
value: '',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Member ID',
name: 'viewer_mem_id',
id: 'viewer_mem_id',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Address',
name: 'viewer_address',
id: 'viewer_address',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Phone [Home]',
name: 'viewer_phone_home',
id: 'viewer_phone_home',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Phone [Mobile]',
name: 'viewer_phone_mobile',
id: 'viewer_phone_mobile',
fieldCls: 'fieldcolor',
width: 280
},{
xtype: 'displayfield',
fieldLabel: 'Phone [Work]',
name: 'viewer_phone_work',
id: 'viewer_phone_work',
fieldCls: 'fieldcolor',
width: 280
}]
});
问题是第一次加载时显示如下
一旦图像加载然后刷新,它就会给我所需的布局
我想这个问题是由于图像大小而发生的。如何解决这个问题?
对不起英语不好
问候
最佳答案
通过添加监听器并将加载事件绑定(bind)到元素找到了正确的方法
var v_profile_image = Ext.widget('image', {
src: '',
style: { display: 'block', margin: 'auto' },
name: 'profile_pic'
});
v_profile_image.on('load', function(e) {
this.up('panel').doLayout();
}, v_profile_image, { element: 'el' });
关于javascript - 如何修复此 extjs 布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6973243/