【发布时间】:2020-01-17 10:29:11
【问题描述】:
我正在使用电子和 Angular 创建一个应用程序。
目前要加载我的 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()
};
}
特别是
win.loadFile(`file://${__dirname}/dist/index.html`)
但是,当我运行代码时,我不断收到错误消息。
Not allowed to load local resource:
我不确定如何为电子应用加载 index.html 文件。正确的语法是什么。
我尝试了“index.html”和“./index.html”,但似乎找不到解决方案。
任何关于放置什么的帮助将不胜感激
【问题讨论】:
-
显示项目结构
-
你读过这个吗? electronjs.org/docs/tutorial/…
标签: javascript html electron load