我的index.html中有一个按钮,当我单击该按钮时,我想打开第二个窗口。
我已经在我的index.js中添加了以下内容:
const button = document.getElementById('newtask');
button.addEventListener('click', () => {
newtaskwindow();
});
function newtaskwindow() {
const BrowserWindow = remote.BrowserWindow;
const win = new BrowserWindow({
height: 400,
width: 600
});
win.loadURL('createtasks.html');
}
在npm start上,出现以下错误:
最佳答案
我必须创建第二个js文件并输入:
const button = document.getElementById('newtask');
button.addEventListener('click', () => {
newtaskwindow();
});
function newtaskwindow() {
const remote = require('electron').remote;
const BrowserWindow = remote.BrowserWindow;
const win = new BrowserWindow({
height: 600,
width: 800
});
win.loadURL('createtasks.html');
}
关于javascript - 如何在 Electron 点击按钮中打开第二个窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60893635/