簡體   English   中英

ElectronJS ReferenceError:導航器未定義

[英]ElectronJS ReferenceError: navigator is not defined

我正在嘗試在電子上制作自定義標題欄。 但是當我啟動我的應用程序時,我遇到了“ReferenceError: navigator is not defined”問題。 請幫忙。 這是我的 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')});

這不能在main process 中執行。 主進程用於管理渲染器進程 Electron 主進程不會有任何導航器。 導航器是瀏覽器的屬性。

渲染器負責將代碼渲染到 browserWindow。 因此,您可以在渲染器而非主渲染器處訪問 browserWindow 的導航器。

因此,請將其移至您想要自定義標題欄的渲染器。

這將非常有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM