【发布时间】:2018-01-08 09:22:33
【问题描述】:
当我通过 Visual Studio Code 运行我的 Electron 应用程序时,会加载主进程,然后启动 index.html 页面。在index.js 脚本中,我将浏览器窗口重定向到名为startup.html 的本地html 文件,该文件位于我的脚本文件夹中,它只是应用程序的子文件夹。 index.html 页面甚至没有启动,应用程序生成错误消息:
不允许加载本地资源
在 DevTools 控制台中,它还显示了它正在尝试加载的资源:
file:///usr/local/lib/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/scripts/ui/startup/startup.html
如果我从项目的根文件夹运行npm start,应用程序会正确启动,index.html 和 startup.html 页面都会加载。
Visual Studio Code 通过以下方式启动电子:
/usr/local/bin/electron
这似乎与仅使用 npm start 启动它不同。不知道有什么区别。
附注:在我添加代码以启动 startup.html 之前,应用程序将从 Visual Studio Code 运行。加了startup.html才不行。
这可能是什么原因造成的?
【问题讨论】:
标签: electron