亚洲精品中文免费|亚洲日韩中文字幕制服|久久精品亚洲免费|一本之道久久免费

<optgroup id="cczp1"><ruby id="cczp1"><cite id="cczp1"></cite></ruby></optgroup>
  • <acronym id="cczp1"></acronym>
    <acronym id="cczp1"><option id="cczp1"><ol id="cczp1"></ol></option></acronym>
    <delect id="cczp1"></delect>
    <center id="cczp1"></center>
    <delect id="cczp1"></delect><em id="cczp1"><button id="cczp1"><blockquote id="cczp1"></blockquote></button></em>
    1. <optgroup id="cczp1"><td id="cczp1"><dfn id="cczp1"></dfn></td></optgroup>

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

      為了在 electron 渲染進(jìn)程中引入BrowserWindow,使用了這樣一個(gè)語句

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

      運(yùn)行時(shí)會(huì)報(bào)錯(cuò):Cannot read properties of undefined (reading ‘BrowserWindow’)

      出錯(cuò)原因

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

      解決方案

      步驟1. 在項(xiàng)目根目錄下安裝@electron/remote包:

      npm install @electron/remote –save

      步驟2. 在主進(jìn)程中,設(shè)置webPreferences選項(xiàng)

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

      步驟3. 在主進(jìn)程中進(jìn)行初始化

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

      步驟4. 在渲染進(jìn)程中引入BrowservWindow:

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

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

      相關(guān)推薦

      聯(lián)系我們

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