gpt4 book ai didi

javascript - 无法加载资源:net::ERR_FILE_NOT_FOUND Angular

转载 作者:太空狗 更新时间:2023-10-29 18:37:54 25 4
gpt4 key购买 nike

我使用 electron 构建我的应用程序,这些错误发生在 chrome 控制台中。否则,如果我通过 ng serve 运行它,我的应用程序运行良好。错误如下:

Failed to load resource: net::ERR_FILE_NOT_FOUND
polyfills.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
styles.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
vendor.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
main.bundle.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
/C:/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND

我在 dist 文件夹中的 index.html 文件是:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>IMS</title>
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="styles.50e334ed602d9817f7d7.bundle.css" rel="stylesheet"/></head>
<body>

<app-root>Loading...</app-root>

<script type="text/javascript" src="inline.9c6676de3e2948b5be6b.bundle.js"></script><script type="text/javascript" src="polyfills.e19c18e1070c8c3aa743.bundle.js"></script><script type="text/javascript" src="vendor.e2a9b8f51e6c245f32be.bundle.js"></script><script type="text/javascript" src="main.eb7ca8d005a358b399e4.bundle.js"></script></body>
</html>

我的 index.html 文件在 src 文件夹中的代码是:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>IMS</title>
<base href="./">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>

<app-root>Loading...</app-root>

</body>
</html>

最佳答案

https://angular.io/docs/ts/latest/guide/router.html

Add the base element just after the <head> tag. If the app folder is the application root, as it is for our application, set the href value exactly as shown here.

<base href="/">告诉 Angular 路由器 URL 的静态部分是什么。然后路由器只修改 URL 的剩余部分。在您的 src/index.html 中将您的 Base href 设置为 '/'

<base href="/"> 

您可以了解更多关于 base href here 的信息

关于javascript - 无法加载资源:net::ERR_FILE_NOT_FOUND Angular ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50576438/

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