2016-07-23 100 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' 
     } 
    ] 
});