Uncaught TypeError: Cannot destructure property ‘dialog‘ of ‘require(...).remote‘ as it is undefined

解决 Uncaught TypeError: Cannot destructure property ‘dialog’ of ‘require(…).remote’ as it is undefined.

从v9版本开始,remote除非将设置enableRemoteModule为true,否则不允许在渲染器上使用。

const mainWindow = new BrowserWindow({
 width: 800,
 height: 600,
 webPreferences: {
   preload: path.join(__dirname, 'preload.js'),
   nodeIntegration: true,
   contextIsolation: false,
   enableRemoteModule:true,  //添加即可解决问题
 }
})

你可能感兴趣的:(js,javascript)