Electron.remote is undefined

后端 未结 3 473
暖寄归人
暖寄归人 2020-12-16 09:23

I have trouble with using Electron. As you can see the title, when i load remote module, it saids it is undefined. This is the code of entry js:

const electr         


        
3条回答
  •  忘掉有多难
    2020-12-16 10:19

    In electron 10.0.0, remoteModule is set false by default. So, if you want to use const {BrowserWindow, dialog } = require('electron').remote; in JavaScript file, then you must set enableRemoteModule as true in webPreferences.

    const w = new BrowserWindow({
        webPreferences: {
            enableRemoteModule: true
        }
    }); 
    

    link: https://github.com/electron/electron/blob/master/docs/breaking-changes.md#default-changed-enableremotemodule-defaults-to-false

提交回复
热议问题