2013-05-25 23 views
0

我想在我的自定義視圖類中使用Sencha的Ext.draw.Component繪製一個圓,但它沒有顯示任何圓。我粘貼了代碼以供參考。如何在自定義視圖班製作圈子?

我也嘗試在我的Main類中定義類型組件的變量,但是這樣做時編譯器給出了一個錯誤,指出類型組件是未知的。

//主類

Ext.define('GS0.view.Main', { 
    extend: 'Ext.tab.Panel', 
    xtype: 'main', 
    requires: [ 
     'Ext.TitleBar', 
     'Ext.Video', 
     'Ext.Carousel', 
     'Ext.Container', 
     'Ext.draw.Component', 
     'Ext.Img' 
    ], 
    config: { 
     tabBarPosition: 'bottom', 

     items: [ 
      { 
       iconCls: 'home', 
       xtype: 'carousel', 
       ui  : 'dark', 
       direction: 'horizontal', 

       items: [ 
        { 
         xtype: 'draw', 
         type: 'circle', 
         radius: 50, 
         x: 100, 
         y: 100, 
         fill: '#2d2d2d' 
        }, 
        { 
         xtype: 'img', 
         src: 'images/nm.jpg' 
        } 
       ] 
      } 
     ] 
    } 
}); 


// Circle Class 
Ext.define('GS0.view.CC', { 
    extend: 'Ext.draw.Component', 
    xtype: 'cc', 

    config: { 
     type: 'circle', 
     cx: 100, 
     cy: 100, 
     r: 25, 
     fillStyle: 'blue' 
    } 
}); 

回答

0

嘗試修改您的項目在GSO.view.Main

items: [{ 
    iconCls: 'home', 
    xtype: 'carousel', 
    ui  : 'dark', 
    direction: 'horizontal', 
    items: [{ 
     xtype: 'draw', 
     items:[{ 
      type: 'circle', 
      fill: '#79BB3F', 
      radius: 100, 
      x: 100, 
      y: 100 
     }] 
    },{ 
     xtype: 'img', 
     src: 'images/nm.jpg' 
    }] 
}] 

圓代碼應添加作爲項到的xtype =繪製塊。

+0

映我這樣做,但它讓我看到以下錯誤:遺漏的類型錯誤:期待在instanceof檢查的功能,但得到# in surface.js – Mridul

+0

嗯別的東西可能會導致這個問題。這裏是一個工作示例小提琴http://jsfiddle.net/blessenm/fmu9P/ – blessenm

+0

小提琴是完美的,但仍然不能讓它運行。順便說一句,哪個sencha版本是你用的?感覺這是一個版本問題。我正在使用sencha 2.2.1開源版本。 Circle.js位於繪圖包中的Sprite文件夾內。 – Mridul

0

我想我加載Main的方式是一個問題。這裏是代碼。你能發現任何錯誤嗎? PS請參閱線Ext.viewport.add(Ext.create(GS0.view.main))

Ext.Loader.setPath({ 
    'Ext': 'touch/src', 
    'GS0': 'app' 
}); 
//</debug> 

Ext.application({ 
    name: 'GS0', 

    requires: [ 
     'Ext.MessageBox' 
    ], 

    views: [ 
     'Main' 
    ], 

    icon: { 
     '57': 'resources/icons/Icon.png', 
     '72': 'resources/icons/Icon~ipad.png', 
     '114': 'resources/icons/[email protected]', 
     '144': 'resources/icons/[email protected]' 
    }, 

    isIconPrecomposed: true, 

    startupImage: { 
     '320x460': 'resources/startup/320x460.jpg', 
     '640x920': 'resources/startup/640x920.png', 
     '768x1004': 'resources/startup/768x1004.png', 
     '748x1024': 'resources/startup/748x1024.png', 
     '1536x2008': 'resources/startup/1536x2008.png', 
     '1496x2048': 'resources/startup/1496x2048.png' 
    }, 

    launch: function() { 
     // Destroy the #appLoadingIndicator element 
     Ext.fly('appLoadingIndicator').destroy(); 

     // Initialize the main view 
     Ext.Viewport.add(Ext.create('GS0.view.Main')); 
    }, 

    onUpdated: function() { 
     Ext.Msg.confirm(
      "Application Update", 
      "This application has just successfully been updated to the latest version. Reload now?", 
      function(buttonId) { 
       if (buttonId === 'yes') { 
        window.location.reload(); 
       } 
      } 
     ); 
    } 
}); 
相關問題