在index.html文件中引入了renderer.js
<script>
require('./renderer.js')
</script>
但是renderer.js文件中写任何代码都不生效,感觉像没有引入。
另外在main.js文件中使用alert,会提示 A javascript Error occurred in the main process Uncaught Exception: ReferenceError: alert is not defined
你确定???

新版本默认contextIsolation: true导致的,下面增加一条contextIsolation: false
所以示例代码 应该是:
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
})