const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, ‘preload.js’),
***nodeIntegration:true,
contextIsolation: false,***//渲染进程 require is not defined
enableRemoteModule: true, // 这一行是解决remote无效的问题的
}
})
该博客介绍了如何配置Electron应用,允许在渲染进程中使用Node.js集成,解决`remote`模块无效的问题。通过设置`nodeIntegration`为`true`和`contextIsolation`为`false`,并启用`enableRemoteModule`,可以实现Electron应用的预加载脚本和远程模块的正常使用。
1408

被折叠的 条评论
为什么被折叠?



