【发布时间】:2026-01-28 02:05:01
【问题描述】:
我在我的应用程序中使用以下代码作为 xtype。我的列表项以我想要的方式出现,但是当我单击一个项目时,每次单击应该加载带有数据的新页面的项目时都会出现此错误:未捕获的 TypeError: Object function (){h.apply(this ,arguments)} 没有方法“setActiveItem”。知道如何解决吗?引用的项目行在代码中进行了注释。
这是我的代码:
var AppsBack = new Ext.Toolbar({
dock: 'top',
items: [{
text: 'back',
ui: 'back',
handler: function(){
Home.setActiveItem('home'); //Here is the second problem
}
}]
});
var AppsDetails = new Ext.Panel({
id: "appsdetails",
tpl: "{game}",
dockedItems: [AppsBack]
});
var AppsList = new Ext.List({
id: "appslist",
store: AppsStore,
layout: 'card',
emptyText: "No game found",
itemTpl: "{game}",
listeners: {
itemtap: function(view, index, item, e) {
var rec = view.getStore().getAt(index);
AppsDetails.update(rec.data);
AppsBack.setTitle(rec.data.game);
Home.setActiveItem('appsdetails') //Here is the first problem
}
}
});
var AppsListWrapper = new Ext.Panel({
id: "appslistwrapper",
layout: 'card',
items: [AppsList],
dockedItems: []
});
var Home = Ext.extend(Ext.Panel, {
id: "home",
iconCls: 'home',
title: 'Home',
fullscreen: true,
layout: 'card',
cardSwitchAnimation: 'slide',
initComponent: function() {
Ext.apply(this, {
items: [AppsListWrapper, AppsDetails]
});
Home.superclass.initComponent.apply(this,arguments)
}
});
Ext.reg('appsList', Home);
感谢您的帮助
经过几次操作,我发现我遇到此问题的唯一原因是因为我正在尝试扩展面板。换句话说,如果我使用 新的Ext.Panel 而不是 Ext.extend(Ext.Panel, {... 一切正常,除了在这种情况下我不能使用 xtype。有什么想法吗?
【问题讨论】:
标签: javascript extjs