在线不卡日本ⅴ一区v二区_精品一区二区中文字幕_天堂v在线视频_亚洲五月天婷婷中文网站

  • <menu id="lky3g"></menu>
  • <style id="lky3g"></style>
    <pre id="lky3g"><tt id="lky3g"></tt></pre>

    在Electron開發(fā)中不能使用remote模塊怎么辦

    為了在 electron 渲染進程中引入BrowserWindow,使用了這樣一個語句

    const BrowserWindow = require(“electron”).remote.BrowserWindow

    運行時會報錯:Cannot read properties of undefined (reading ‘BrowserWindow’)

    出錯原因

    這是由于electron 版本所造成的問題。由于用的是目前的最新版本@v19.0.8, 而remote在electron12中就已經(jīng)廢棄了remote模塊,如果需要使用,則應自己安裝remote包。

    解決方案

    步驟1. 在項目根目錄下安裝@electron/remote包:

    npm install @electron/remote –save

    步驟2. 在主進程中,設置webPreferences選項

    webPreferences: { nodeIntegration: true, contextIsolation: false, enableRemoteModule: true, // 使用remote模塊},

    步驟3. 在主進程中進行初始化

    require(“@electron/remote/main”).initialize();require(“@electron/remote/main”).enable(mainWindow.webContents);

    步驟4. 在渲染進程中引入BrowservWindow:

    const BrowserWindow = require(“@electron/remote”).BrowserWindow;

    鄭重聲明:本文內容及圖片均整理自互聯(lián)網(wǎng),不代表本站立場,版權歸原作者所有,如有侵權請聯(lián)系管理員(admin#wlmqw.com)刪除。
    上一篇 2022年7月18日 13:08
    下一篇 2022年7月18日 13:08

    相關推薦

    聯(lián)系我們

    聯(lián)系郵箱:admin#wlmqw.com
    工作時間:周一至周五,10:30-18:30,節(jié)假日休息