Electron中渲染进程require报错‘require is not defined’
这是由于渲染进程(页面文件)中使用了第三方框架,如: jQuery等与node冲突造成的,主进程代码如下:
function createWindow() {
window = new BrowserWindow({
width: 950,
height: 600,
title: "Login",
frame: false,
transparent: true,
center: true,
resizable: false
})
window.loadFile(`${
__dirname}/resources/views/index.html`)
window.webContents.openDevTools()
window.on('closed', () => {
window = null
})
}
渲染进程代码如下:
<script