如何从电子应用程序中删除此菜单栏:

它还说“Hello World”(这是因为我下载了电子预构建,一旦我打包应用程序就会消失吗?)我没有编码这些到html,所以我不知道如何得到它!-


当前回答

在main.js的这一行之前:

mainWindow = new BrowserWindow({width: 800, height: 900})

mainWindow.setMenu(null) //this will r menu bar

其他回答

电子12.0.6:

    let mainWindow = new BrowserWindow({
        autoHideMenuBar: true
    });

即使autoHideMenuBar: true,你仍然可以用Alt键切换菜单栏。

所以要完全隐藏它,使用mainwindow。setmenu (null)

在main.js的这一行之前:

mainWindow = new BrowserWindow({width: 800, height: 900})

mainWindow.setMenu(null) //this will r menu bar

这里的大多数答案对于新版本无效。对于9.0或更高版本,Menu.setApplicationMenu(null);应该工作。顺便说一下,Menu从electron package导出:const {Menu} = require('electron');

setMenu(空);是不是autohidemenu的最佳答案会在应用程序启动时显示


    function createWindow(){
        const win = new BrowserWindow({
            width: 1500,
            height: 800,
            webPreferences:{
                nodeIntergration: true
            }
        });
        win.setMenu(null);
    win.loadFile("index.html");
    }
    app.whenReady().then(createWindow);