Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何激活tab开关中tabpanel的第二项_Javascript_Extjs - Fatal编程技术网

Javascript 如何激活tab开关中tabpanel的第二项

Javascript 如何激活tab开关中tabpanel的第二项,javascript,extjs,Javascript,Extjs,我有标签面板。在tab开关(第二个tab)上,有时我希望根据某些条件在tab2panel1和tab2panel2上渲染。这是我的配置 { "xtype" : "tabpanel", "tabPosition" : "left", "layout" : "fit", "tab

我有标签面板。在tab开关(第二个tab)上,有时我希望根据某些条件在tab2panel1和tab2panel2上渲染。这是我的配置

{
            "xtype" : "tabpanel",
            "tabPosition" : "left",
            "layout" : "fit",
            "tabRotation" : 0.0,
            "items" : [ 
                {
                    "xtype" : "panel",
                    "title" : "tab1",
                    "icon" : "classic/resources/images/Profile_active.png",
                    "layout" : "card",
                    "items" : [ 
                    {
                         "xtype" : "panel",
                        "title" : "tab1panel1",
                    }]
                }, 
                {
                    "xtype" : "panel",
                    "title" : "tab1",
                    "icon" : "classic/resources/images/Profile_active.png",
                    "layout" : "card",
                    "items" : [ 
                    {
                         "xtype" : "panel",
                        "title" : "tab2panel1",
                    },{
                         "xtype" : "panel",
                        "title" : "tab2panel1",
                    }]
                },  
            ]
        }
这是我正在尝试的,但它正在变为tab1。不是选项卡2的面板项

tabchange: function (tab, newTab, oldTab) {
        let _this = this,
            cardItems = newTab.items;
        
        if (tab.changeValue == true) {
             newTab.getLayout().setActiveItem(1);
        }
    }

但这导致了1的标签。不在选项卡内的项目。这里有任何帮助。

我认为这是个错误的地方,最好听一下标签激活事件。大概是这样的:

{
    "xtype": "tabpanel",
    "tabPosition": "left",
    "layout": "fit",
    "tabRotation": 0.0,
    "items": [{
        "xtype": "panel",
        "title": "tab1",
        "icon": "classic/resources/images/Profile_active.png",
        "layout": "card",
        "items": [{
            "xtype": "panel",
            "title": "tab1panel1",
            html: "Tab1Panel1"
        }]
    }, {
        "xtype": "panel",
        "title": "tab1",
        "icon": "classic/resources/images/Profile_active.png",
        "layout": "card",
        "items": [{
            "xtype": "panel",
            "title": "tab2panel1",
            html: "Tab2Panel1"
        }, {
            "xtype": "panel",
            "title": "tab2panel2",
            html: "Tab2Panel2"
        }],
        listeners: {
            activate: function (panel) {
                // Some random condition
                const activeItemIndex = Math.round(Math.random());
                panel.setActiveItem(activeItemIndex);
            }
        }
    }]
}

我会使用数据绑定。可以在viewModel内设置条件,并在两个子面板上绑定隐藏条件。如果你设置了小提琴,我可以为你添加这个。