2012-02-07 96 views
0

這使我發瘋,我嘗試了許多不同的選項。我正在閱讀所有材料here,試圖將盡可能多的ExtJS 4塞進我的大腦中以儘可能地完成一個項目。在圖紙和圖表部分有兩個例子。下面,第一個示例繪製一個黃色圓圈,第二個示例繪製一個圓圈。爲什麼?ExtJS 4繪圖和製圖示例不是繪圖

第一例(畫一個黃色圓圈):

Ext.application({ 
name: 'HelloExt', 
launch: function(){ 
    var drawComponent = Ext.create('Ext.draw.Component', { 
     viewBox: false, 
     items: [{ 
      type: 'circle', 
      fill: '#ffc', 
      radius: 100, 
      x: 100, 
      y: 100 
     }] 
    }); 

    Ext.create('Ext.Window', { 
     width: 230, 
     height: 230, 
     layout: 'fit', 
     items: [drawComponent] 
    }).show(); 
} 
}); 

第二個例子(不消耗圈):

Ext.application({ 
name: 'HelloExt', 
launch: function(){ 
    // Create a draw component 
    var drawComponent = Ext.create('Ext.draw.Component', { 
     viewBox: false 
    }); 

    // Create a window to place the draw component in 
    Ext.create('Ext.Window', { 
     width: 220, 
     height: 230, 
     layout: 'fit', 
     items: [drawComponent] 
    }).show(); 

    // Add a circle sprite 
    var myCircle = drawComponent.surface.add({ 
     type: 'circle', 
     x: 100, 
     y: 100, 
     radius: 100, 
     fill: '#cc5' 
    }); 
} 
}); 

我試着加入雪碧到drawComponent和無數的方式只有那些作品是我將它作爲drawComponent實例化中的項目的聲明成員。我在控制檯中沒有發現錯誤。

回答

1

該修復包括將.show(true)添加到精靈語句的末尾。就像這樣:

var myCircle = drawComponent.surface.add({ 
    type: 'circle', 
    x: 100, 
    y: 100, 
    radius: 100, 
    fill: '#cc5' 
}).show(true); 

我真希望這一直是ExtJS的4文檔。