【问题标题】:Add icon to a panel in Sencha在 Sencha 的面板中添加图标
【发布时间】:2012-06-05 14:07:02
【问题描述】:

我是煎茶的新手。我正在尝试向面板添加图标,但我的代码不起作用。

   Ext.define('components.ImagePanel', {
    extend: 'Ext.Panel',    
    initialize: function () {
        this.callParent(arguments);
        var image = {
            xtype: "image",
            src: 'icon.png',
            width:100,
            height:100
                }, 
            scope: this
        };
 this.add([image]);
});

我做错了什么?

【问题讨论】:

    标签: icons extjs


    【解决方案1】:

    哇,甚至都不知道有图片 xtype。

    不管怎样……

    要使用 xtype,您需要使用 Ext.widget(); 创建它

    所以你的代码应该是这样的:

    Ext.define('components.ImagePanel', {
    extend: 'Ext.Panel',    
    initialize: function () {
        this.callParent(arguments);
        var image = Ext.widget('image',{
            xtype: "image",
            src: 'icon.png',
            width:100,
            height:100
        });
        this.add([image]);
    };
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多