【问题标题】:ExtJS 4 class loading failsExtJS 4 类加载失败
【发布时间】:2011-09-29 17:33:13
【问题描述】:

我有类似这样的代码:

Ext.define('GG.view.Workbench', {
    extend: 'Ext.container.Viewport',
    layout: 'fit',
    items: [
        {
            xtype: 'container',
            layout: 'border',
            items: [
                {
                    region: 'center',
                    items: [
                        Ext.create('GG.view.Foo')
                    ]
                },
                {
                    region: 'south',
                    items: [
                        Ext.create('GG.view.Bar')
                    ]
                }
            ]
        }
    ],

    initComponent: function() {
        this.callParent(arguments);
    }
});

发生的情况是当两个Ext.create 调用在那里时,代码不起作用。

这是我在 Chrome 上得到的:

Uncaught TypeError: object is not a function
(anonymous function)
Ext.ClassManager.instantiateext-debug.js:6428
(anonymous function)ext-debug.js:2414
(anonymous function)

我应该如何使用这个Ext.create

【问题讨论】:

    标签: javascript extjs extjs4


    【解决方案1】:

    你是过度嵌套,你必须在每次创建类时执行的方法中这样做

    Ext.define('GG.view.Workbench', {
        extend: 'Ext.container.Viewport',
        layout: 'border',
    
        initComponent: function() {
            var me = this;
    
            Ext.apply(me, {
                items : me.buildItems()
            });
    
            me.callParent(arguments);
        },
    
        buildItems: function() {
            return [
                {
                    region: 'center',
                    items: [
                        Ext.create('GG.view.Foo')
                    ]
                },
                {
                    region: 'south',
                    items: [
                        Ext.create('GG.view.Bar')
                    ]
                }
            ];
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 2018-04-20
      • 1970-01-01
      • 2019-03-19
      相关资源
      最近更新 更多