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'
    }
});
4

2 回答 2

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/Icon@2x.png',
        '144': 'resources/icons/Icon~ipad@2x.png'
    },

    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();
                }
            }
        );
    }
});
于 2013-05-27T18:30:19.180 回答
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=draw 块中。

于 2013-05-26T02:38:50.453 回答