Electron的版本为20.0.2
渲染进程中代码如下:
如第一张图所示,nodeIntegration设置为true,console控制台报如下错:
解决方案:
nodeIntegration设置为true后还需要设置contextIsolation为false。
webPreferences: {
// preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: false
}