2012-06-05 24 views
0

我是sencha新手。我正在嘗試向面板添加一個圖標,但我的代碼無法工作。將圖標添加到Sencha的面板中

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

我在做什麼錯了?

回答

0

哇,甚至不知道有一個圖像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]); 
}; 
}); 
+0

對不起,沒有奏效。 –