[英]How do I load the index.html file on electron?
I'm creating an app with electron and Angular.我正在创建一个带有电子和 Angular 的应用程序。
Currently to load my index.html file my code looks like this.目前加载我的 index.html 文件我的代码看起来像这样。
exports.window = function window() {
this.createWindow = (theBrowserWindow) => {
// Create the browser window.
let win = new theBrowserWindow({
width: 900,
height: 600,
webPreferences: {
nodeIntegration: true
},
resizable:false
});
// and load the index.html of the app.
win.loadFile(`file://${__dirname}/dist/index.html`)
// Chrome Dev Tools
win.webContents.openDevTools()
};
}
in particular特别是
win.loadFile(`file://${__dirname}/dist/index.html`)
However when i run the code I keep getting the error message.但是,当我运行代码时,我不断收到错误消息。
Not allowed to load local resource:
I'm unsure how to load the index.html file for the electron app.我不确定如何为电子应用程序加载 index.html 文件。 What the right syntax is.
正确的语法是什么。
I've tried "index.html" and "./index.html" but can't seem to find the solution.我试过“index.html”和“./index.html”,但似乎找不到解决方案。
Any help on what to put would be appreciated任何有关放置内容的帮助将不胜感激
I'm not sure of your project structure, but in my Electron app when loading the window, I have the following when loading the html page:我不确定你的项目结构,但在我的 Electron 应用程序中加载窗口时,加载 html 页面时我有以下内容:
mainWindow.loadFile(path.join(__dirname, 'index.html'));
In my case currently, index.html is in the same directory as the js file that is executing the window creation.在我目前的情况下, index.html与正在执行窗口创建的 js 文件位于同一目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.