gpt4 book ai didi

javascript - Electron 加载 index.html 但不加载其余的包文件

转载 作者:行者123 更新时间:2023-11-30 19:38:56 25 4
gpt4 key购买 nike

我们有一个 Electron 应用程序,想要使用 loadUrl() 加载渲染器包。

win=new BrowserWindow({ /* ... */ })
win.loadURL(`file://${path.join(__dirname, '../../render/build/index.html')}`);

在 html 文件中,我们加载 React Bundle

<script type="text/javascript" src="/js/app-my-hash.bundle.js"></script>

但是,正如预期的那样,找不到该文件,因为我想我需要以某种方式设置项目的根目录。我得到这个错误

Failed to load resource: net::ERR_FILE_NOT_FOUND

我在 electron 端(或 webpack 端)缺少什么设置才能使它正常工作?

最佳答案

index.html 中无需手动更新即可添加相对路径的另一种方法是包含,

homepage property in package.json.

举个例子,

{
"name": "electron-project",
"homepage": "./", # Add this line
#.... all remaining properties
}

Stackoverflow Source

关于javascript - Electron 加载 index.html 但不加载其余的包文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55618945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com