簡體   English   中英

Extjs 4.1:如此奇怪的錯誤:未捕獲TypeError:無法讀取未定義的屬性'items'

[英]Extjs 4.1: So strange error: Uncaught TypeError: Cannot read property 'items' of undefined

你可以改變樣本: app/simple/app/Viewport.js到這個:

您將在Chrome控制台中收到此錯誤消息:

未捕獲的TypeError:無法讀取未定義的ext-all.js的屬性'items':18 Ext.cmd.derive.getDockedItems

但如果你評論這個:

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

一切都好。

Ext.define('AM.view.Viewport', {
        extend : 'Ext.container.Viewport',

        layout: 'border',
        items : [{
                    border : false,
                    region : 'north',
                    xtype : 'progressbar',
                    text : 'Ready',
                    height : 20
                }, {
                    region : 'west',
                    xtype : 'userlist',
                    width:300
                }, {
                    region : 'center',
                    xtype : 'treepanel',
                    initComponent : function() {
                        this.callParent();
                    },
                    columns : [{
                                xtype : 'treecolumn',
                                sortable : false,
                                width : 200,
                                text : 'lala',
                                dataIndex : 'text'
                            }, {
                                flex : 1,
                                sortable : false,
                                text : 'haha',
                                dataIndex : 'pars'
                            }]
                }]
    });

1-嘗試使用這樣的Parents參數調用:

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

或者調用超類:

.
.

,initComponent : function() {
     this.callSuper(arguments);
 },
.
.
.

initComponent僅適用於新定義的組件。 在您的情況下'AM.view.Viewport'。 您不能覆蓋作為項目中組件的配置插入的組件的initComponent。 如果要為該treepanel定義initComponent,則必須對其進行擴展,然后將此擴展名放入視口的項目中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM