[英]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.