简体   繁体   English

电子显示空白窗口

[英]Electron shows blank window

My HTML file isn't loading at the tutorial says it would've.我的 HTML 文件没有在教程中加载,说明它会加载。 This is what I have.这就是我所拥有的。 Yes, I've tried doing all sorts of funky stuff involving paths and it doesn't fix the issue.是的,我已经尝试过各种涉及路径的时髦的东西,但它并不能解决问题。

main.js<\/code>

const { app, BrowserWindow } = require('electron');
const path = require("path");

const createWindow = () => {
    const win = new BrowserWindow({
      width: 800,
      height: 600
    })
  
    win.loadFile("index.html")
  }

  app.whenReady().then(() => {
    createWindow()
  })

You might have to change your JavaScript code to have a full path to the HTML file.您可能必须更改 JavaScript 代码才能获得 HTML 文件的完整路径。

Try with the code below, it will configure Electron.试试下面的代码,它将配置 Electron。 In the event listening, it is creating a new BrowserWindow<\/code> with no configuration (although you can add it if you like).在事件侦听中,它正在创建一个没有配置的新BrowserWindow<\/code> (尽管您可以根据需要添加它)。 Then, it is loading the full path to the HTML file.然后,它正在加载 HTML 文件的完整路径。

const electron = require("electron");

const {
  app,
  BrowserWindow
} = electron;

app.on("ready", () => {
  const mainWindow = new BrowserWindow({});
  mainWindow.loadURL(`file://${__dirname}\\index.html`);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 电子窗口显示屏幕截图 - Electron window shows a screenshot of the screen Hot Reload 在 Electron 带有 svelte-routing 的 Svelte 中显示空白屏幕 - Hot Reload shows blank screen in Electron Svelte with svelte-routing Vue CLI 插件 Electron Builder 在构建时显示完整的空白屏幕 - Vue CLI Plugin Electron Builder shows complete blank screen on build Electron 在开发中运行时显示空白屏幕但在生产中运行 - Electron shows blank screen when running in development yet works in production Electron webview 新窗口事件返回 `about:blank` 作为 Url - Electron webview new-window event returning `about:blank` as Url win.reload 显示在电子中显示空白窗口 - win.reload showing showing blank white window in electron window.open以打开有关空白页的PDF显示 - window.open to open PDF shows about blank page 创建现有角度应用程序的电子应用程序时显示空白屏幕 - shows empty blank screen when creating electron app of existing angular app 电子无边框窗口在窗口不聚焦时显示标题栏 - Electron border-less window shows title bar when window is not in focus 当React组件中的音频元素src属性已更改并且在Linux上重新加载窗口时,Electron变为空白 - Electron goes blank when audio element src attribute has changed in a React component and the window reloads on linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM