从 Electron 应用程序中删除菜单栏 [英] Remove menubar from Electron app
问题描述
如何从我的电子应用程序中删除此菜单栏:
How do I remove this menu-bar from my electron apps:
它还说Hello World"(这是因为我下载了预先构建的电子,并且一旦我打包应用程序就会消失吗?).我没有把这些编码到html中,所以我不知道如何把它弄出来!-
Also it says "Hello World"(is this because I downloaded electron pre-built, and will go away once I package the application?). I didn't code these into the html, so I don't know how to get it out!-
推荐答案
你可以使用 w.setMenu(null)
或设置 frame: false
(这也去除了按钮关闭、最小化和最大化选项)在您的窗口上.请参阅 setMenu() 或 BrowserWindow().还要检查这个 线程
You can use w.setMenu(null)
or set frame: false
(this also removes buttons for close, minimize and maximize options) on your window. See setMenu() or BrowserWindow(). Also check this thread
Electron 现在有 win.removeMenu()
(在 v5.0.0 中添加),删除应用程序菜单而不是使用 win.setMenu(null)
.
Electron now has win.removeMenu()
(added in v5.0.0), to remove application menus instead of using win.setMenu(null)
.
Electron 7.1.x 似乎有一个 win.removeMenu()
不起作用的错误.唯一的解决方法是使用 Menu.setApplicationMenu(null)
,但是,这将禁用所有菜单快捷方式,例如用于切换全屏等的 F11.
Electron 7.1.x seems to have a bug where win.removeMenu()
doesn't work. The only workaround is to use Menu.setApplicationMenu(null)
, however, this will disable all the menu shortcuts like F11 for toggling fullscreen etc.
在新版本的 Electron 中,可以在创建 browserWindow 时设置 autoHideMenuBar: true
,按下 Alt 会再次显示菜单栏.
In new versions of Electron, you can set autoHideMenuBar: true
while creating browserWindow, pressing Alt will show the menu bar again.
const mainWindow = new BrowserWindow({
autoHideMenuBar: true,
})
这篇关于从 Electron 应用程序中删除菜单栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!