I am making a electron app but the error said 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.
function createAddItemWindow() {
//Create new window
addItemWindow = new BrowserWindow({
width: 300,
height: 200,
title: 'Add Item',
//The lines below solved the issue
webPreferences: {
nodeIntegration: true
}
})}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.