React NW.JS Menubar设置崩溃

发布于 2025-01-31 01:46:39 字数 575 浏览 1 评论 0原文

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

身边 2025-02-07 01:46:39

对于NW.JS的最新版本,这似乎是一个错误,与React无关。

我可以通过单独运行nw.exe来重新创建崩溃(版本0.64.1),右键单击窗口以打开DevTools,然后在控制台中输入以下内容:

nw.Window.get().menu = new nw.Menu({ type: 'menubar' });

如果我降级到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:

nw.Window.get().menu = new nw.Menu({ type: 'menubar' });

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文