打开新窗口 - Electron [英] Opening new Window - Electron

查看:23
本文介绍了打开新窗口 - Electron的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试在我的 Electron 应用程序上实现一个新窗口.所以我想包含一个按钮,当你点击这个按钮时,应该会打开一个新窗口.我在 Electron 文档中没有找到任何内容,也许你们中的一个可以帮助我.

I'm currently trying to implement a new Window on my Electron App. So I want to include a button, and when you click on this Button, a new Window should be opened. I didn't find anything in the Electron documentation, maybe one of you can help me.

推荐答案

大概是这样的:

const button = document.getElementById('<your_button_id>');
button.addEventListener('click', () => {
  createBrowserWindow();
});

function createBrowserWindow() {
  const remote = require('electron').remote;
  const BrowserWindow = remote.BrowserWindow;
  const win = new BrowserWindow({
    height: 600,
    width: 800
  });

  win.loadURL('<url>');
}

这篇关于打开新窗口 - Electron的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆