2013-05-03 82 views
0

我正在嘗試使用Sencha Touch和Ext.draw.Component將畫布繪製到屏幕上。我無法做任何事情。Sencha Touch:Ext.draw.Component根本不工作

這是我的主視圖,它已被設置爲初始視圖。

Ext.define('Booking.view.panelOne', { 
    extend: 'Ext.Panel', 
    alias: 'widget.panelOne', 
    requires: [ 
     'Booking.view.drawComponent' 
    ], 
    config: { 
     itemId: 'panelOne', 
     ui: 'light', 
     layout: { 
      type: 'card' 
     }, 
     scrollable: 'horizontal', 
     items: [ 
      { 
       xtype: 'drawComponent' 
      } 
     ] 
    } 
}); 

這是我的draw.Component的代碼,我試圖用它來渲染基本形狀到屏幕上。

Ext.define('Booking.view.drawComponent', { 
    extend: 'Ext.draw.Component', 
    alias: 'widget.drawComponent', 

    config: { 
     docked: 'left', 
     height: '100%', 
     itemId: 'myComponent', 
     width: '100%' 
    }, 

    initialize: function() { 
     this.callParent(); 

     Booking.view.drawComponent.getSurface('main').add({ 
      type: 'circle', 
      fill: '#79BB3F', 
      radius: 100, 
      x: 100, 
      y: 100 
     }).show(true); 

     Booking.view.drawComponent.surface.add({ 
      type: 'circle', 
      fill: '#000', 
      radius: 100, 
      x: 300, 
      y: 300 
     }).show(true); 
    } 

}); 

我對此深感不解,發現它很不愉快。任何幫助表示讚賞,謝謝。

+0

也許你做錯了什麼......?控制檯中有任何錯誤? – 2013-05-03 16:51:14

+0

http://new.senchafiddle.com/#VoFka/ – 2013-05-03 16:52:27

回答

1

使用getSurface方法,而不是Booking.view.drawComponent

this.getSurface('main').add({ 
    type: 'circle', 
    fill: '#79BB3F', 
    radius: 100, 
    x: 100, 
    y: 100 
}).show(true); 

Here is a link to th fiddle.

0

Booking.view.drawComponent不具有surface屬性。因此調用Booking.view.drawComponent.surface上的add方法會引發錯誤。

See working demo here