import {Menu} from 'electron'
var template = [
{
label: '关闭',
submenu: [
{
label: 'Undo',
accelerator: 'CmdOrCtrl+Z',
role: 'undo'
}
]
}]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
- 渲染进程内
// Menu 类只能在主进程中使用,但你也可以 在渲染过程中通过remote模块使用它
var remote = require('electron').remote;
var Menu = remote.Menu;
var menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);