2016-07-23 99 views
0

我使用ExtJS 4構建了一個簡單的用戶界面。我創建了兩個視圖類,分別位於視圖文件夾內,名爲MainMenu。在那之後,我按照以下方式將這些類包含進來但是我遇到了一個錯誤。在控制檯中打印了TypeError: item.onAdded is not a function。在這裏我的代碼ExtJS TypeError:item.onAdded不是函數

Main.js

Ext.define('Ext1.view.Main', { 
    extend: 'Ext.container.Container', 
    requires:[ 
     'Ext.tab.Panel', 
     'Ext.layout.container.Border' 
    ], 
    items : [ 
     { 
      xtype : 'menume' 
     } 
    ] 
}); 

Menu.js

Ext.define('Ext1.view.Menu',{ 
    alias : 'widget.menume', 
     title: 'User Form', 
    height: 150, 
    width: 300, 
    bodyPadding: 10, 
    defaultType: 'textfield', 
    items: [ 
     { 
      fieldLabel: 'First Name', 
      name: 'firstName' 
     }, 
     { 
      fieldLabel: 'Last Name', 
      name: 'lastName' 
     }, 
     { 
      xtype: 'datefield', 
      fieldLabel: 'Date of Birth', 
      name: 'birthDate' 
     } 
    ] 
}); 

的application.js

Ext.define('Ext1.Application', { 
    name: 'Ext1', 

    extend: 'Ext.app.Application', 

    views: [ 
     'Ext1.view.Menu', 'Ext1.view.Main' 
    ], 

    controllers: [ 
     // TODO: add controllers here 
    ], 

    stores: [ 
     // TODO: add stores here 
    ] 
}); 

爲什麼我有有這個錯誤?

回答

2

因爲Ext1.view.Menu沒有擴展任何東西。它至少需要(有物品)一個容器。

0
Ext.define('Ext1.view.Menu',{ 
    extend: 'Ext.menu.Menu'// add this 
    alias : 'widget.menume', 
     title: 'User Form', 
    height: 150, 
    width: 300, 
    bodyPadding: 10, 
    defaultType: 'textfield', 
    items: [ 
     { 
      fieldLabel: 'First Name', 
      name: 'firstName' 
     }, 
     { 
      fieldLabel: 'Last Name', 
      name: 'lastName' 
     }, 
     { 
      xtype: 'datefield', 
      fieldLabel: 'Date of Birth', 
      name: 'birthDate' 
     } 
    ] 
});