Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ext4组件展示_Javascript_Extjs_Javascript Framework - Fatal编程技术网

Javascript Ext4组件展示

Javascript Ext4组件展示,javascript,extjs,javascript-framework,Javascript,Extjs,Javascript Framework,请不要客气,我正在学习Ext4 当我运行下面的代码时,我得到了以下错误:uncaughttypeerror:无法调用undefined的方法“getCount”。当我注释掉NS.view.ImplementationStatus.Legend中的代码:list.show(),错误就会消失。所以我认为这与此有关,但我真的不明白这会从何而来 Ext.define('NS.controller.ImplementationStatuses', { extend: 'Ext.app.Contro

请不要客气,我正在学习Ext4

当我运行下面的代码时,我得到了以下错误:
uncaughttypeerror:无法调用undefined的方法“getCount”
。当我注释掉NS.view.ImplementationStatus.Legend中的代码:
list.show()
,错误就会消失。所以我认为这与此有关,但我真的不明白这会从何而来

Ext.define('NS.controller.ImplementationStatuses', {
    extend: 'Ext.app.Controller',
    stores: ['ImplementationStatuses'],
    models: ['ImplementationStatus'],
    views: ['ImplementationStatus.Legend'],
    init: function() {
        var view = Ext.widget('statusLegend');
    }
});

Ext.define('NS.view.ImplementationStatus.Legend', {
    extend: 'Ext.window.Window',
    alias : 'widget.statusLegend',
    views: ['ImplementationStatus.List'],
    initComponent: function() {
        console.log("Initializing NS.view.ImplementationStatus.Legend");

        // This creates the list of statuses
        var list = Ext.create('NS.view.ImplementationStatus.List', {});
        list.show();

        // Define the list of items
        this.items = [list];
    }
});

Ext.define('NS.view.ImplementationStatus.List', {
    extend: 'Ext.panel.Panel',
    alias : 'widget.statusList',
    initComponent: function() {
        console.log("Initializing NS.view.ImplementationStatus.List");
    }
});

首先,当您为init、initComponent等方法创建重写时,还必须从原始类调用方法。例如:

Ext.window.Window.prototype.initComponent.apply(this, arguments);

完成方法后,错误不再显示。

扩展Ext组件类的推荐方法是像使用一样使用initComponent函数,但最后需要调用
this.callParent(参数)


您可以在指南的所有视图中看到这种模式:

我认为这是做事情的3倍方式。请参阅下面我的答案,了解新的推荐方法。我认为你是对的。另一种方式似乎是extjs3.x方式。既然我说过它是针对ExtJS4.x的,我就给你一个正确的答案。