Electron使用romote报错 : Uncaught TypeError: Cannot read property ‘BrowserWindow‘ of undefined
Electron的API方法和模块也是分为可以在主进程和渲染进程中使用。那如果我们想在渲染进程中使用主进程中的模块方法时,可以使用Electron Remote解决在渲染和主进程间的通讯
在Electron 10.x中,enableRemoteModule的默认值为false,也就是默认情况下是不支持使用remote模块的,因此使用remote模块的应用程序需要将enableRemoteModule显式设置为true。
mainWindow = new BrowserWindow({
width:400,
height:400,
webPreferences: {
nodeIntegration: true, // 集成node环境
enableRemoteModule: true // 使用remote模块
}
}) //设置打开的窗口大小