[英]How do I use node.js in index.html without nodeIntegration [electron]
[英]How do I load the index.html file on electron?
我正在创建一个带有电子和 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”,但似乎找不到解决方案。
任何有关放置内容的帮助将不胜感激
我不确定你的项目结构,但在我的 Electron 应用程序中加载窗口时,加载 html 页面时我有以下内容:
mainWindow.loadFile(path.join(__dirname, 'index.html'));
在我目前的情况下, index.html与正在执行窗口创建的 js 文件位于同一目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.