【问题标题】:Object has no method getId sencha对象没有方法 getId sencha
【发布时间】:2014-03-19 06:17:01
【问题描述】:

我正在尝试为 sencha 中的工具栏创建一个视图并将其导入到我的文件中,但它一直在抛出 Uncaught TypeError: Object [object Object] has no method 'getId' 告诉我我做错了什么。 我猜它不允许只为工具栏创建视图。

查看/mainTool.js

Ext.define('test.view.mainTool',{

requires:['Ext.field.Search'
  ,'Ext.Toolbar'
],

config:{docked:'top',
ui:'normal',


items:[
  {
xtype: 'searchfield',
    placeHolder: 'Search...',
    left: true,
    id:'mainSearch',
width: 200,

  },
  {
xtype:'button',
ui:'action',

text:'filter',
id:'filter'
  },
  {xtype:'spacer'},
  {
xtype:'button',
ui:'action',
text:'showOnMap',
id:'showOnMap'
  },
  {
xtype:'button',
ui:'action',
iconCls:'arrow_left',
id:'back'
  },
  {
xtype:'button',
ui:'action',
iconCls:'home',
    id:'home'
       }

    ]

  }


});

app.js

Ext.application({
requires: [
  'Ext.dataview.List',
  'Ext.Panel',
  'Ext.Spacer',
  'test.view.list',
  'test.view.mainTool',
  'Ext.List',
  'test.model.list1model',
  'test.store.list1store'
],
launch : function(){
    list1 =Ext.create('test.view.list');
    list2 =Ext.create('test.view.list');
    list2.setHidden(true);
    maintool=Ext.create('test.view.mainTool');
    Ext.create('Ext.Container',{
      id:'contain',
      layout:'hbox',

      fullscreen:true,
      items:[
   maintool,
    list1,
    {xtype:'spacer'},
    list2
      ]
    })
  }
});

【问题讨论】:

  • 您在 app.js 项目部分中指定的与 mainTool 相关的问题。
  • 抱歉不能,因为我无法重现该问题。我试过 Sencha Fiddle 但没有成功。只需尝试从项目部分删除maintool。你会看到错误消失了。
  • 但是我的工具栏不会出现,我尝试在 app.js 中添加工具栏然后没有出现错误。

标签: extjs view sencha-touch toolbar


【解决方案1】:

您忘记将 extend: 'Ext.Toolbar' 添加到您的 test.view.mainTool 课程中。不要忘记,简单地定义一个类而不扩展 Ext 组件并不能创建一个有效的 Ext View。

【讨论】:

  • 执行此操作时出现以下错误。 Uncaught TypeError: Object prototype may only be an Object or null
  • 这可能来自你的其他班级,例如test.view.list。检查此粘贴箱:pastebin.com/UjK8nJWR
  • 除了添加扩展之外,您做了哪些更改,现在可以使用?请指出我的错误。你能把那个代码作为答案发布吗,我会接受的:)
  • Nothing else :) (不要忘记extend: 'Ext.Toolbar' 后面的逗号)并且只使用 Application.launch() 中的工具栏(不使用您定义的其他类)
  • 我不会发布整个代码,因为它与您的问题无关。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-06-01
  • 2012-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-11
  • 2014-05-17
相关资源
最近更新 更多