Javascript mainWindow.loadFile(`file://${uuuu dirname}/index.html`)-即使在使用';回勾';
我尝试使用以下代码加载HTML文件 “mainWindow.loadFile(Javascript mainWindow.loadFile(`file://${uuuu dirname}/index.html`)-即使在使用';回勾';,javascript,electron,Javascript,Electron,我尝试使用以下代码加载HTML文件 “mainWindow.loadFile(文件://${\uu dirname}/index.html)” 然而,无论我做了什么,它都不起作用,只有“index.html”起作用。我真的什么都做了。安装,重新安装。它以前工作得很好 这一次,我按照官方网站的指示如下,突然那种加载文件的方式不起作用了 $ git clone https://github.com/electron/electron-quick-start $ cd electron-quick-s
文件://${\uu dirname}/index.html
)”
然而,无论我做了什么,它都不起作用,只有“index.html”起作用。我真的什么都做了。安装,重新安装。它以前工作得很好
这一次,我按照官方网站的指示如下,突然那种加载文件的方式不起作用了
$ git clone https://github.com/electron/electron-quick-start
$ cd electron-quick-start
$ npm install && npm start
下面是main.js。为什么我只需要使用旧方法突然加载文件?哈哈
const { app, BrowserWindow } = require("electron");
function createWindow() {
mainWindow = new BrowserWindow({ width: 800, height: 600 });
mainWindow.loadFile(`file://${__dirname}/index.html`);
mainWindow.on("closed", function() {
mainWindow = null;
});
}
app.on("ready", createWindow);
app.on("window-all-closed", function() {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", function() {
if (mainWindow === null) {
createWindow();
}
});
可能是你的打字错误!用文件代替flie?LOL刚刚找到原因 当我快速安装电子感应加速器时,它基本上是
mainWindow.loadFile(`file://${__dirname}/index.html`);
,我应该使用“loadURL”lol抱歉。这种类型不是我写的:)其中一个家伙建议改变发帖的风格,这样才能适应。最初的帖子是“文件”:)所以,换言之,可能没有打字错误。@Edgarsugardoughtuntjin您可能需要修复问题和标题中的打字错误。干杯。谢谢:)bjbk