我正在尝试在电子上创建自定义标题栏。但是,当我启动我的应用程序时,出现“ ReferenceError:导航器未定义”问题。请帮忙。这是来自main.js的代码片段
// 1. Require the installed module
const customTitlebar = require('custom-electron-titlebar');
// 2. Create the custom titlebar with your own settings
// To make it work, we just need to provide the backgroundColor property
// Other properties are optional.
let MyTitleBar = new customTitlebar.Titlebar({ backgroundColor: customTitlebar.Color.fromHex('#03a9f4')});
答案 0 :(得分:2)
无法在main process中执行。 主要过程是管理renderer process的过程。在Electron主流程中将没有任何导航器。 navigator是浏览器的属性。
渲染器负责将代码渲染到browserWindow。因此,您可以在渲染器而不是main处访问browserWindow的导航器。
因此,请将其移至您要自定义标题栏的渲染器。
这将很好地工作。