React NW.JS Menubar设置崩溃
我使用npx create-nw-react-app ...
命令行创建了一个React NW.JS应用程序。我在Linux环境中工作。到目前为止,一切都很好。我设法使其使用一些自定义配置(例如窗口尺寸或标题)来使用。但是,当我尝试设置菜单时,应用程序刚刚撞到桌面。正如文档所说,我在index.tsx文件中写道:
var menu = new nw.Menu({ type: 'menubar' });
var submenu = new nw.Menu();
submenu.append(new nw.MenuItem({ label: 'Item A' }));
submenu.append(new nw.MenuItem({ label: 'Item B' }));
menu.append(new nw.MenuItem({
label: 'First Menu',
submenu: submenu
}));
nw.Window.get().menu = menu;
没有变量为无效,但这不起作用。有什么想法吗?
感谢您的帮助!
I created a React NW.js application using the npx create-nw-react-app ...
command line. I'm working in a Linux environment. So far, so good. I managed to make it work with some custom configuration like window size or title. But when I tried to setup a menu, the application just crashed to desktop. As the documentation said, I wrote in the index.tsx file:
var menu = new nw.Menu({ type: 'menubar' });
var submenu = new nw.Menu();
submenu.append(new nw.MenuItem({ label: 'Item A' }));
submenu.append(new nw.MenuItem({ label: 'Item B' }));
menu.append(new nw.MenuItem({
label: 'First Menu',
submenu: submenu
}));
nw.Window.get().menu = menu;
No variables are null, but this is not working. Any idea?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于NW.JS的最新版本,这似乎是一个错误,与React无关。
我可以通过单独运行
nw.exe
来重新创建崩溃(版本0.64.1),右键单击窗口以打开DevTools,然后在控制台中输入以下内容:如果我降级到0.62。 2,同一命令在没有崩溃的情况下工作。看来已经打开了一个问题: https://github.com/nwjs/ nw.js/essess/7870
This appears to be a bug with the latest builds of NW.js and is not related to React.
I can recreate the crash by simply running
nw.exe
by itself (version 0.64.1), right-clicking the window to open DevTools, and entering the following in the console:If I downgrade to 0.62.2, the same command works without crashing. It looks like an issue has already been opened: https://github.com/nwjs/nw.js/issues/7870