contextmenu:function(t,cur,e){
if(!this.cmenu){
this.cmenu=new Ext.menu.Menu({
items:[{
id:tab.id+'-close',
text:'Close',
handler:function(){
tab.remove(cur);
}
},{
text:'Close Other'
},{
text:'Close All'
}]
})
}
e.stopEvent();
this.cmenu.showAt(e.getPoint());
}
}
ctxItem:false,
listeners:{
contextmenu:function(t,cur,e){
if(!this.cmenu){
this.cmenu=new Ext.menu.Menu({
items:[{
id:tab.id+'-close',
text:'Close',
handler:function(){
tab.remove(tab.ctxItem);
}
},{
text:'Close Other'
},{
text:'Close All'
}]
})
}
e.stopEvent();
tab.ctxItem=cur;
this.cmenu.showAt(e.getPoint());
}
}
这下才行,我发现在TabPanel的contextmenu事件有点小猫腻,每二个参数说的是传的当前的tab结果在colse里面得不到。还是你每下次点击的那个tab,所以要设置一个全局的变量来保存。这里我用的是ctxItem。希望以后谁遇到这个问题能好些。