【问题标题】:How to make a circle in a customized view class?如何在自定义视图类中制作一个圆圈?
【发布时间】:2013-05-25 18:25:33
【问题描述】:

我试图在我的自定义视图类中使用 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'
    }
});

【问题讨论】:

    标签: html extjs sencha-touch sencha-touch-2.1 sencha-charts


    【解决方案1】:

    尝试修改 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 块中。

    【讨论】:

    • Anh 我这样做了,但它向我显示了以下错误:未捕获的 TypeError: Expecting a function in instanceof check, but got # in surface.js
    • 嗯,可能是其他原因导致了问题。这是一个工作示例jsfiddle.net/blessenm/fmu9P的小提琴
    • Anh 小提琴是完美的,但仍然无法运行。顺便说一句,你用的是哪个煎茶版本?感觉这是版本问题。我使用的是 sencha 2.2.1 开源版本。 Circle.js 位于绘图包中的 Sprite 文件夹中。
    • 我试图完全按照您在小提琴中所做的事情,但仍然无法做到。真的对可能的解决方案感到困惑。
    • Ext.draw.Component 的源文件是否在您的 Sencha Touch 文件夹中?我认为您必须手动下载并添加它
    【解决方案2】:

    我认为我加载 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();
                    }
                }
            );
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-30
      • 2013-12-23
      • 2023-03-16
      • 2013-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多