日期:2014-05-20 浏览次数:20695 次
new Ext.TabPanel({  
        id: "mainTab",  
        renderTo: "div1",  
        width: 500,  
        height: 300,  
        activeTab: 0,  
        defaults: {  
            autoScroll: true,  
            autoHeight:true,  
            style: "padding:5"  
        },  
        items:[  
               {title:"normal", tabTip:"mormal", html:"tab1", iconCls:"add"},  
            {title:"ajax1", autoLoad:"messagebox.action", iconCls:"delete"},  
            {title:"ajax2", autoLoad:{url:"test.action", params:"p1=v1", nocache:true}, iconCls:"search"},  
            {title:"event", iconCls:"save", listeners:{activate:activateHandler}}  
        ],  
        enableTabScroll: true  
    });  
      
    function activateHandler(tab){  
        //alert(tab.title);  
    }  
          var index = 0;  
    function addTab(){  
        var tabs = Ext.getCmp("mainTab");  
          
        var t = tabs.getItem("tab"+index);  
        if(t) tabs.remove(t);  
          
        tabs.add({  
            id: "tab" + (++index),  
            title: "NewTab" + index,  
            html: "new tab" + index,  
            closable: true  
        }).show();  
    }  
      
    //按钮渲染到div1元素之前  
    new Ext.Button({  
        text:"add tab",  
        handler:addTab,  
        iconCls:"add"  
    }).render(document.body, "div1");
------解决方案--------------------
看官方网站上的例子http://www.extjs.org.cn/