踩坑electron渲染进程renderer,解决require is not defined的问题
解决办法
nodeIntegration: true
如果还不能解决加上
contextIsolation: false
完整代码
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
frame: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: false
}
})
win.loadFile('index.html')
}