[英]How to fix Uncaught ReferenceError: require is not defined - How to fix it?
I am making a electron app but the error said Uncaught ReferenceError: require is not defined
我正在制作一个电子应用程序,但错误说
Uncaught ReferenceError: require is not defined
This is my code:这是我的代码:
const remote = require('electron').remote
var minimise = document.getElementById('minimise');
var maximise = document.getElementById('maximise');
var quit = document.getElementById('quit');
minimise.addEventListener('click', minimiseApp);
maximise.addEventListener('click', maximiseApp);
quit.addEventListener('click', quitApp);
function minimiseApp() {
remote.BrowserView.getFocusedWindow().minimize();
}
function maximiseApp() {
remote.BrowserView.getFocusedWindow().maximize();
}
function quitApp() {
remote.BrowserView.getFocusedWindow().close();
}
How to fix it?如何解决? Please give me solutions But they should at least work!
请给我解决方案 但他们至少应该工作!
Please specify node integration as true when the browser window (where this HTML file is embedded) was originally created in the main process.当浏览器窗口(嵌入此 HTML 文件的位置)最初在主进程中创建时,请将节点集成指定为 true。
function createAddItemWindow() {
//Create new window
addItemWindow = new BrowserWindow({
width: 300,
height: 200,
title: 'Add Item',
//The lines below solved the issue
webPreferences: {
nodeIntegration: true
}
})}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.