JSTree 上下文菜单不显示

JSTree context menu not displaying

我正在尝试在我的 javascript 项目中设置上下文菜单。这是我的代码,用于树的 json 数据和树的创建。

let json_data = {
        'core': {
            'data': [
                {
                    'text': 'First',
                    'state': {
                        'opened': false,
                        'selected': false
                    },
                    'children': [
                        {
                            'text': 'First'
                        },
                        {
                            'text': 'Second'
                        },
                        {
                            'text': 'Third'
                        }
                    ]
                },
                {
                    'text': 'Second',
                    'state': {
                        'opened': false,
                        'selected': false
                    },
                    'children': [
                        {
                            'text': 'First'
                        },
                        {
                            'text': 'Second'
                        },
                        {
                            'text': 'Third'
                        }
                    ]
                },
                {
                    'text': 'Third',
                    'state': {
                        'opened': false,
                        'selected': false
                    },
                    'children': [
                        {
                            'text': 'First'
                        },

                    ]
                }
            ]


        },
        'plugins': ['contextmenu'],
        'contextmenu' : {
            'items': this.customMenuOptions
        }

    };
    tree.jstree(json_data).bind("select_node.jstree", function(e, data){});
    console.log(tree[0]);
}

这里是我的 customMenuOptions 代码:

customMenuOptions(node) {
        console.log(node);
        let items = {
            'item1': {
                'label': 'item1',
                'action': function(){}
            },
            'item2': {
                'label': 'item2',
                'action': function(){}
            }
        };

        return items;

    }

我知道右键单击功能有效,因为每当我右键单击树上的任何节点时,customMenuOptions 顶部的打印语句都会出现在控制台中;但是,菜单没有显示。任何帮助,将不胜感激。谢谢

通过增加上下文菜单元素的 z-index 解决了这个问题,这样它就不会隐藏在其他元素后面。