javascript - 如何修复此 extjs 布局?

标签 javascript html css extjs extjs4

这是我的分机号

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          
        }]
});

问题是第一次加载时显示如下

enter image description here

一旦图像加载然后刷新,它就会给我所需的布局

enter image description here

我想这个问题是由于图像大小而发生的。如何解决这个问题?

对不起英语不好

问候

最佳答案

通过添加监听器并将加载事件绑定(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/

相关文章:

javascript - 如何以编程方式将对象添加到键相同的对象?

css - 图片布局空间大的div位置

html - 有没有办法在html+css中制作边框?

javascript - 单击时影响任何 div 的属性

css - 如何将 45deg 元素调整到视口(viewport)边界

javascript - 如何创建响应式导航栏?

javascript - JS 重定向 url 已更改

html - 我的 Bootstrap 代码有什么问题?

css - Safari 字体粗细问题,文字太粗

Javascript 模态 - 禁用正文滚动但使用 css 启用模态