Ext4组件显示

Ext4 Component Show

本文关键字:显示 组件 Ext4      更新时间:2023-09-26

请谅解我正在学习Ext4。

当我运行下面的代码,我得到这个错误:Uncaught TypeError: Cannot call method 'getCount' of undefined。当我在nsview . 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");
    }
});

扩展Ext Component类的推荐方法是使用initComponent函数,就像你正在使用的,但在最后你需要调用this.callParent(arguments);

您可以在指南中看到该模式在所有视图中使用:http://docs.sencha.com/ext-js/4-0/#!/指导/application_architecture

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

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

方法完成后错误不再显示